Compare commits
No commits in common. "9c09fe7cecb79e5f5d7940284a72ee2c3460b097" and "a26dabaa5a42a54425a44a73c642c4935521eb96" have entirely different histories.
9c09fe7cec
...
a26dabaa5a
12
.clang-format
Normal file
12
.clang-format
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
BasedOnStyle: Microsoft
|
||||||
|
CompactNamespaces: 'false'
|
||||||
|
FixNamespaceComments: 'false'
|
||||||
|
NamespaceIndentation: All
|
||||||
|
AllowShortBlocksOnASingleLine: 'true'
|
||||||
|
AllowShortCaseLabelsOnASingleLine: 'true'
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: Always
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: 'true'
|
||||||
|
PointerAlignment: Left
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,5 +2,4 @@ Luna.iso
|
|||||||
toolchain/
|
toolchain/
|
||||||
.vscode/
|
.vscode/
|
||||||
initrd/boot/
|
initrd/boot/
|
||||||
moon/target/**
|
moon/target/**
|
||||||
**/Cargo.lock
|
|
@ -1,7 +0,0 @@
|
|||||||
use crate::bootboot::{BOOTBOOT, BOOTBOOT_MAGIC};
|
|
||||||
use crate::util::get_bootboot;
|
|
||||||
|
|
||||||
pub fn check_magic() -> () {
|
|
||||||
let boot: BOOTBOOT = get_bootboot();
|
|
||||||
assert_eq!(boot.magic, BOOTBOOT_MAGIC[..4]);
|
|
||||||
}
|
|
@ -5,13 +5,9 @@ mod video;
|
|||||||
mod bootboot;
|
mod bootboot;
|
||||||
mod panic;
|
mod panic;
|
||||||
mod util;
|
mod util;
|
||||||
mod init;
|
|
||||||
|
|
||||||
use video::Color;
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
init::check_magic();
|
video::clear(0xffffffff);
|
||||||
video::clear(Color::White);
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
@ -1,51 +1,27 @@
|
|||||||
#![allow(dead_code)]
|
|
||||||
|
|
||||||
use crate::bootboot::{BOOTBOOT, BOOTBOOT_FB};
|
use crate::bootboot::{BOOTBOOT, BOOTBOOT_FB};
|
||||||
use crate::util::get_bootboot;
|
use crate::util::get_bootboot;
|
||||||
|
|
||||||
use BOOTBOOT_FB as FB;
|
use BOOTBOOT_FB as FB;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
pub fn put_pixel(x: u32, y: u32, color: u32) -> () {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum Color {
|
|
||||||
Black = 0x00000000,
|
|
||||||
Blue = 0xff0000ff,
|
|
||||||
Green = 0xff00ff00,
|
|
||||||
Cyan = 0xff00ffff,
|
|
||||||
Red = 0xffff0000,
|
|
||||||
Magenta = 0xffff00ff,
|
|
||||||
Brown = 0xff231709,
|
|
||||||
LightGray = 0xffb9b8b5,
|
|
||||||
DarkGray = 0xff808080,
|
|
||||||
LightBlue = 0xff317ecc,
|
|
||||||
LightGreen = 0xff6aab8e,
|
|
||||||
LightCyan = 0xffe0ffff,
|
|
||||||
LightRed = 0xffff7377,
|
|
||||||
Pink = 0xffffc0cb,
|
|
||||||
Yellow = 0xffffff00,
|
|
||||||
White = 0xffffffff,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn put_pixel(x: u32, y: u32, color: Color) -> () {
|
|
||||||
let boot: BOOTBOOT = get_bootboot();
|
let boot: BOOTBOOT = get_bootboot();
|
||||||
let ptr: u64 = FB + (boot.fb_scanline * y) as u64 + (x * 4) as u64;
|
let ptr: u64 = FB + (boot.fb_scanline * y) as u64 + (x * 4) as u64;
|
||||||
unsafe { *(ptr as *mut u32) = color as u32 };
|
unsafe { *(ptr as *mut u32) = color };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_rect(x: u32, y: u32, width: u32, height: u32, color: Color) -> () {
|
pub fn draw_rect(x: u32, y: u32, width: u32, height: u32, color: u32) -> () {
|
||||||
let boot: BOOTBOOT = get_bootboot();
|
let boot: BOOTBOOT = get_bootboot();
|
||||||
for i in y..(y + height)
|
for i in y..(y + height)
|
||||||
{
|
{
|
||||||
let addr: u64 = FB + (boot.fb_scanline * i) as u64 + (x * 4) as u64;
|
let addr: u64 = FB + (boot.fb_scanline * i) as u64 + (x * 4) as u64;
|
||||||
for ptr in (addr..(addr + (width*4) as u64)).step_by(4)
|
for ptr in (addr..(addr + (width*4) as u64)).step_by(4)
|
||||||
{
|
{
|
||||||
unsafe { *(ptr as *mut u32) = color as u32 };
|
unsafe { *(ptr as *mut u32) = color };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear(color: Color) -> () {
|
pub fn clear(color: u32) -> () {
|
||||||
let boot: BOOTBOOT = get_bootboot();
|
let boot: BOOTBOOT = get_bootboot();
|
||||||
draw_rect(0, 0, boot.fb_width, boot.fb_height, color)
|
draw_rect(0, 0, boot.fb_width, boot.fb_height, color)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user