mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
wip
This commit is contained in:
2
Makefile
2
Makefile
@@ -32,7 +32,7 @@ clean:
|
||||
@rm -rf build
|
||||
|
||||
run: $(iso)
|
||||
@qemu-system-x86_64 -hda $(iso)
|
||||
@qemu-system-x86_64 -s -hda $(iso)
|
||||
|
||||
iso: $(iso)
|
||||
|
||||
|
||||
@@ -48,6 +48,11 @@ setup_page_tables:
|
||||
; map first P3 entry to a huge page that starts at address 0
|
||||
mov dword [p3_table], 0b10000011 ; present + writable + huge
|
||||
|
||||
; recursive map P4
|
||||
mov eax, p4_table
|
||||
or eax, 0b11 ; present + writable
|
||||
mov [p4_table + 511 * 8], eax
|
||||
|
||||
ret
|
||||
|
||||
enable_paging:
|
||||
@@ -133,7 +138,9 @@ p4_table:
|
||||
p3_table:
|
||||
resb 4096
|
||||
stack_bottom:
|
||||
resb 64
|
||||
; TODO a >= 80 byte stack is enough. Theoretically we could use the memory
|
||||
; of the p3 table as a hack (it won't override the important first entry)
|
||||
resb 4096
|
||||
stack_top:
|
||||
|
||||
section .rodata
|
||||
|
||||
@@ -27,6 +27,15 @@ SECTIONS {
|
||||
|
||||
.text :
|
||||
{
|
||||
*(.text)
|
||||
*(.text .text.*)
|
||||
}
|
||||
|
||||
.rodata : {
|
||||
*(.rodata .rodata.*)
|
||||
}
|
||||
|
||||
.data.rel.ro : {
|
||||
*(.data.rel.ro.local*) *(.data.rel.ro .data.rel.ro.*)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
13
src/lib.rs
13
src/lib.rs
@@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#![feature(no_std, lang_items)]
|
||||
#![feature(core_str_ext, const_fn)]
|
||||
#![feature(no_std, lang_items, asm)]
|
||||
#![feature(core_str_ext, const_fn, range_inclusive)]
|
||||
#![no_std]
|
||||
|
||||
extern crate rlibc;
|
||||
@@ -26,15 +26,18 @@ use core::fmt::Write;
|
||||
#[macro_use]
|
||||
mod vga_buffer;
|
||||
|
||||
mod memory;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn rust_main(multiboot_address: usize) {
|
||||
// ATTENTION: we have a very small stack and no guard page
|
||||
use vga_buffer::{Writer, Color};
|
||||
|
||||
let multiboot = unsafe{multiboot2::load(multiboot_address)};
|
||||
|
||||
|
||||
vga_buffer::clear_screen();
|
||||
let multiboot = unsafe{multiboot2::load(multiboot_address)};
|
||||
memory::init(multiboot);
|
||||
|
||||
|
||||
let mut writer = Writer::new(Color::Blue, Color::LightGreen);
|
||||
writer.write_byte(b'H');
|
||||
let _ = writer.write_str("ello! ");
|
||||
|
||||
Reference in New Issue
Block a user