diff --git a/.gitignore b/.gitignore index 402798b..3086f8d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ aarch64-rpi/LIC* aarch64-rpi/*.bin aarch64-rpi/*.dat aarch64-rpi/*.elf + +mykernel-rust/target +mykernel-rust/Cargo.lock \ No newline at end of file diff --git a/images/Makefile b/images/Makefile index 042126b..182fedf 100644 --- a/images/Makefile +++ b/images/Makefile @@ -20,9 +20,9 @@ mkimg: mkimg.c initrd.bin: @mkdir initrd initrd/sys 2>/dev/null | true ifeq ($(PLATFORM),x86) - cp ../mykernel/mykernel.x86_64.elf initrd/sys/core + cp ../mykernel-rust/mykernel.x86_64.elf initrd/sys/core else - cp ../mykernel/mykernel.aarch64.elf initrd/sys/core + cp ../mykernel-rust/mykernel.aarch64.elf initrd/sys/core endif @cd initrd && (find . | cpio -H hpodc -o | gzip > ../initrd.bin) && cd .. @rm -r initrd 2>/dev/null || true diff --git a/mykernel-rust/Cargo.toml b/mykernel-rust/Cargo.toml new file mode 100755 index 0000000..f8f5a19 --- /dev/null +++ b/mykernel-rust/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "mykernel-rust" +version = "0.0.1" +authors = ["Author "] +edition = "2018" + +[dependencies] +rlibc = "1.0" + diff --git a/mykernel-rust/Makefile b/mykernel-rust/Makefile new file mode 100644 index 0000000..ceb9f77 --- /dev/null +++ b/mykernel-rust/Makefile @@ -0,0 +1,10 @@ + +all: mykernel.x86_64.elf + +# Kernel build +mykernel.x86_64.elf: src/** + objcopy -O elf64-x86-64 -B i386 -I binary font.psf font.o + cargo xbuild --target ./triplets/mykernel-x86.json + # Using this causes the kernel to exceed the 2 MB limit + # cargo build -Z build-std=core,alloc --target ./triplets/$mykernel-x86.json + cp ./target/mykernel-x86/debug/mykernel-rust mykernel.x86_64.elf \ No newline at end of file diff --git a/mykernel-rust/font.o b/mykernel-rust/font.o new file mode 100644 index 0000000..3f51137 Binary files /dev/null and b/mykernel-rust/font.o differ diff --git a/mykernel-rust/font.psf b/mykernel-rust/font.psf new file mode 100644 index 0000000..3e67693 Binary files /dev/null and b/mykernel-rust/font.psf differ diff --git a/mykernel-rust/mykernel.x86_64.elf b/mykernel-rust/mykernel.x86_64.elf new file mode 100755 index 0000000..183b925 Binary files /dev/null and b/mykernel-rust/mykernel.x86_64.elf differ diff --git a/mykernel-rust/rust-toolchain b/mykernel-rust/rust-toolchain new file mode 100755 index 0000000..07ade69 --- /dev/null +++ b/mykernel-rust/rust-toolchain @@ -0,0 +1 @@ +nightly \ No newline at end of file diff --git a/mykernel-rust/src/bootboot.rs b/mykernel-rust/src/bootboot.rs new file mode 100644 index 0000000..82a05ad --- /dev/null +++ b/mykernel-rust/src/bootboot.rs @@ -0,0 +1,702 @@ +/* automatically generated by rust-bindgen */ + +pub const BOOTBOOT_MAGIC: &'static [u8; 5usize] = b"BOOT\0"; +pub const PROTOCOL_MINIMAL: u32 = 0; +pub const PROTOCOL_STATIC: u32 = 1; +pub const PROTOCOL_DYNAMIC: u32 = 2; +pub const PROTOCOL_BIGENDIAN: u32 = 128; +pub const LOADER_BIOS: u32 = 0; +pub const LOADER_UEFI: u32 = 4; +pub const LOADER_RPI: u32 = 8; +pub const FB_ARGB: u32 = 0; +pub const FB_RGBA: u32 = 1; +pub const FB_ABGR: u32 = 2; +pub const FB_BGRA: u32 = 3; +pub const MMAP_USED: u32 = 0; +pub const MMAP_FREE: u32 = 1; +pub const MMAP_ACPI: u32 = 2; +pub const MMAP_MMIO: u32 = 3; +pub const INITRD_MAXSIZE: u32 = 16; +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct MMapEnt { + pub ptr: u64, + pub size: u64, +} +#[test] +fn bindgen_test_layout_MMapEnt() { + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(MMapEnt)) + ); + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(MMapEnt)) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).ptr as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(MMapEnt), + "::", + stringify!(ptr) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).size as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(MMapEnt), + "::", + stringify!(size) + ) + ); +} +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct BOOTBOOT { + pub magic: [u8; 4usize], + pub size: u32, + pub protocol: u8, + pub fb_type: u8, + pub numcores: u16, + pub bspid: u16, + pub timezone: i16, + pub datetime: [u8; 8usize], + pub initrd_ptr: u64, + pub initrd_size: u64, + pub fb_ptr: *mut u8, + pub fb_size: u32, + pub fb_width: u32, + pub fb_height: u32, + pub fb_scanline: u32, + pub arch: BOOTBOOT__bindgen_ty_1, + pub mmap: MMapEnt, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union BOOTBOOT__bindgen_ty_1 { + pub x86_64: BOOTBOOT__bindgen_ty_1__bindgen_ty_1, + pub aarch64: BOOTBOOT__bindgen_ty_1__bindgen_ty_2, + _bindgen_union_align: [u64; 8usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct BOOTBOOT__bindgen_ty_1__bindgen_ty_1 { + pub acpi_ptr: u64, + pub smbi_ptr: u64, + pub efi_ptr: u64, + pub mp_ptr: u64, + pub unused0: u64, + pub unused1: u64, + pub unused2: u64, + pub unused3: u64, +} +#[test] +fn bindgen_test_layout_BOOTBOOT__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::core::mem::size_of::(), + 64usize, + concat!( + "Size of: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).acpi_ptr as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(acpi_ptr) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).smbi_ptr as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(smbi_ptr) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).efi_ptr as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(efi_ptr) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).mp_ptr as *const _ + as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mp_ptr) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).unused0 as *const _ + as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(unused0) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).unused1 as *const _ + as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(unused1) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).unused2 as *const _ + as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(unused2) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).unused3 as *const _ + as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(unused3) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct BOOTBOOT__bindgen_ty_1__bindgen_ty_2 { + pub acpi_ptr: u64, + pub mmio_ptr: u64, + pub efi_ptr: u64, + pub unused0: u64, + pub unused1: u64, + pub unused2: u64, + pub unused3: u64, + pub unused4: u64, +} +#[test] +fn bindgen_test_layout_BOOTBOOT__bindgen_ty_1__bindgen_ty_2() { + assert_eq!( + ::core::mem::size_of::(), + 64usize, + concat!( + "Size of: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).acpi_ptr as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(acpi_ptr) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).mmio_ptr as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(mmio_ptr) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).efi_ptr as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(efi_ptr) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).unused0 as *const _ + as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(unused0) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).unused1 as *const _ + as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(unused1) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).unused2 as *const _ + as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(unused2) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).unused3 as *const _ + as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(unused3) + ) + ); + assert_eq!( + unsafe { + &(*(::core::ptr::null::())).unused4 as *const _ + as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(unused4) + ) + ); +} +#[test] +fn bindgen_test_layout_BOOTBOOT__bindgen_ty_1() { + assert_eq!( + ::core::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(BOOTBOOT__bindgen_ty_1)) + ); + assert_eq!( + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(BOOTBOOT__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).x86_64 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1), + "::", + stringify!(x86_64) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).aarch64 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT__bindgen_ty_1), + "::", + stringify!(aarch64) + ) + ); +} +#[test] +fn bindgen_test_layout_BOOTBOOT() { + assert_eq!( + ::core::mem::size_of::(), + 144usize, + concat!("Size of: ", stringify!(BOOTBOOT)) + ); + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(BOOTBOOT)) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).magic as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(magic) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(size) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).protocol as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(protocol) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).fb_type as *const _ as usize }, + 9usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(fb_type) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).numcores as *const _ as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(numcores) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).bspid as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(bspid) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).timezone as *const _ as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(timezone) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).datetime as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(datetime) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).initrd_ptr as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(initrd_ptr) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).initrd_size as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(initrd_size) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).fb_ptr as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(fb_ptr) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).fb_size as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(fb_size) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).fb_width as *const _ as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(fb_width) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).fb_height as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(fb_height) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).fb_scanline as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(fb_scanline) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).arch as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(arch) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).mmap as *const _ as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(BOOTBOOT), + "::", + stringify!(mmap) + ) + ); +} +extern "C" { + pub static mut bootboot: BOOTBOOT; +} +extern "C" { + pub static mut environment: *mut custom_ctypes::c_uchar; +} +extern "C" { + pub static mut fb: u8; +} +#[doc = " Display text on screen *"] +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct psf2_t { + pub magic: u32, + pub version: u32, + pub headersize: u32, + pub flags: u32, + pub numglyph: u32, + pub bytesperglyph: u32, + pub height: u32, + pub width: u32, + pub glyphs: u8, +} +#[test] +fn bindgen_test_layout_psf2_t() { + assert_eq!( + ::core::mem::size_of::(), + 33usize, + concat!("Size of: ", stringify!(psf2_t)) + ); + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(psf2_t)) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).magic as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(psf2_t), + "::", + stringify!(magic) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).version as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(psf2_t), + "::", + stringify!(version) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).headersize as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(psf2_t), + "::", + stringify!(headersize) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).flags as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(psf2_t), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).numglyph as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(psf2_t), + "::", + stringify!(numglyph) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).bytesperglyph as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(psf2_t), + "::", + stringify!(bytesperglyph) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).height as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(psf2_t), + "::", + stringify!(height) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).width as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(psf2_t), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { &(*(::core::ptr::null::())).glyphs as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(psf2_t), + "::", + stringify!(glyphs) + ) + ); +} +extern "C" { + pub static mut _binary_font_psf_start: custom_ctypes::c_uchar; +} +pub mod custom_ctypes { pub type c_int = i64; pub type c_uchar = u64; } diff --git a/mykernel-rust/src/main.rs b/mykernel-rust/src/main.rs new file mode 100644 index 0000000..9cd1d84 --- /dev/null +++ b/mykernel-rust/src/main.rs @@ -0,0 +1,115 @@ +#![no_std] +#![no_main] + +#[cfg(not(test))] +use core::panic::PanicInfo; + +#[allow(dead_code)] +#[allow(non_snake_case)] +#[allow(non_camel_case_types)] +mod bootboot; + +// Required for -Z build-std flag. +extern crate rlibc; + +/// Entry point for the Operating System. +#[no_mangle] // don't mangle the name of this function +fn _start() -> ! { + // int x, y, s=bootboot.fb_scanline, w=bootboot.fb_width, h=bootboot.fb_height; + // for(y=0;y ! { + loop {} +} + +fn puts(string: &'static str) { + use bootboot::*; + unsafe { + let font: *mut bootboot::psf2_t = &_binary_font_psf_start as *const u64 as *mut psf2_t; + let (mut kx, mut line, mut mask, mut offs): (u32, u64, u64, u32); + kx = 0; + let bpl = ((*font).width + 7) / 8; + + for s in string.bytes() { + let glyph_a: *mut u8 = (font as u64 + (*font).headersize as u64) as *mut u8; + let mut glyph: *mut u8 = glyph_a.offset( + (if s > 0 && (s as u32) < (*font).numglyph { + s as u32 + } else { + 0 + } * ((*font).bytesperglyph)) as isize, + ); + offs = kx * ((*font).width + 1) * 4; + for _y in 0..(*font).height { + line = offs as u64; + mask = 1 << ((*font).width - 1); + for _x in 0..(*font).width { + let target_location = (&bootboot::fb as *const u8 as u64 + line) as *mut u32; + let mut target_value: u32 = 0; + if (*glyph as u64) & (mask) > 0 { + target_value = 0xFFFFFF; + } + *target_location = target_value; + mask >>= 1; + line += 4; + } + let target_location = (&bootboot::fb as *const u8 as u64 + line) as *mut u32; + *target_location = 0; + glyph = glyph.offset(bpl as isize); + offs += bootboot.fb_scanline; + } + kx += 1; + } + } +} diff --git a/mykernel-rust/triplets/mykernel-x86.json b/mykernel-rust/triplets/mykernel-x86.json new file mode 100644 index 0000000..ddcda71 --- /dev/null +++ b/mykernel-rust/triplets/mykernel-x86.json @@ -0,0 +1,28 @@ +{ + "llvm-target": "x86_64-unknown-none", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "none", + "executables": true, + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "panic-strategy": "abort", + "disable-redzone": true, + "features": "-mmx,-sse,+soft-float", + "dynamic-linking": false, + "relocation-model": "pic", + "code-model": "kernel", + "eliminate-frame-pointer": false, + "exe-suffix": "", + "has-rpath": false, + "no-compiler-rt": true, + "no-default-libraries": true, + "position-independent-executables": false, + "has-elf-tls": true, + "pre-link-args": { + "ld.lld": ["--script=./triplets/mykernel.ld", "./font.o"] + } +} diff --git a/mykernel-rust/triplets/mykernel.ld b/mykernel-rust/triplets/mykernel.ld new file mode 100644 index 0000000..67f33d3 --- /dev/null +++ b/mykernel-rust/triplets/mykernel.ld @@ -0,0 +1,41 @@ +KERNEL_OFFSET = 0xfffffffff8000000; + +PHDRS +{ + boot PT_LOAD FILEHDR PHDRS; /* one single loadable segment */ +} +SECTIONS +{ + . = KERNEL_OFFSET; + mmio = .; . += 0x4000000; + fb = .; . += 0x3E00000; + bootboot = .; . += 4096; + environment = .; . += 4096; + + .text . + SIZEOF_HEADERS : AT(ADDR(.text) - KERNEL_OFFSET + SIZEOF_HEADERS) { + __text_start = .; + KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) /* code */ + . = ALIGN(4096); + __text_end = .; + } :boot + + .rodata : AT(ADDR(.rodata) - KERNEL_OFFSET) { + __rodata_start = .; + *(.rodata*) + . = ALIGN(4096); + __rodata_end = .; + } :boot + + .data : AT(ADDR(.data) - KERNEL_OFFSET) { + __data_start = .; + *(.data*) + . = ALIGN(4096); + __data_end = .; + __bss_start = .; + *(.bss*) + . = ALIGN(4096); + __bss_end = .; + } :boot + + /DISCARD/ : { *(.eh_frame) *(.comment) } +}