mirror of
https://github.com/XunilGroup/XunilOS.git
synced 2026-06-02 14:44:26 +02:00
Add correct framebuffer mapping, so Doom works again, remove unneded
code, add cooperative scheduling on syscalls determined by the reschedule flag, make serial console automatically clear and be a single render, make process_scancodes push to all processes, add a user-facing framebuffer to be mapped, automatically swap buffers inside timer interrupt, update all submodules
This commit is contained in:
@@ -2,17 +2,10 @@ use core::ptr::null;
|
||||
|
||||
use x86_64::structures::paging::OffsetPageTable;
|
||||
|
||||
use crate::{
|
||||
arch::syscall::{malloc, memset},
|
||||
driver::elf::{
|
||||
header::{
|
||||
ET_DYN, ET_EXEC, ET_REL, Elf64Ehdr, Elf64Rel, Elf64Shdr, SHF_ALLOC, SHT_NOBITS, SHT_REL,
|
||||
},
|
||||
program::load_program,
|
||||
reloc::elf_do_reloc,
|
||||
section::elf_sheader,
|
||||
validation::validate_elf,
|
||||
},
|
||||
use crate::driver::elf::{
|
||||
header::{ET_DYN, ET_EXEC, ET_REL, Elf64Ehdr},
|
||||
program::load_program,
|
||||
validation::validate_elf,
|
||||
};
|
||||
|
||||
pub fn load_file(mapper: &mut OffsetPageTable, elf_bytes: &[u8]) -> (*const u8, u64) {
|
||||
@@ -37,70 +30,3 @@ pub fn load_file(mapper: &mut OffsetPageTable, elf_bytes: &[u8]) -> (*const u8,
|
||||
_ => return (null(), 0),
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: make ET_REL work
|
||||
pub unsafe fn elf_load_stage1(hdr: *const Elf64Ehdr) {
|
||||
let shdr = unsafe { elf_sheader(hdr) } as *mut Elf64Shdr;
|
||||
let mut i: u16 = 0;
|
||||
let shnum = unsafe { (*hdr).e_shnum };
|
||||
|
||||
while i < shnum {
|
||||
let section: &mut Elf64Shdr = unsafe { &mut *(shdr.add(i as usize)) };
|
||||
|
||||
if section.sh_type == SHT_NOBITS {
|
||||
if section.sh_size == 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (section.sh_flags & SHF_ALLOC) != 1 {
|
||||
let mem =
|
||||
unsafe { malloc(section.sh_size as usize, section.sh_addralign as usize) };
|
||||
|
||||
if mem.is_null() {
|
||||
continue; // handle OOM
|
||||
}
|
||||
|
||||
unsafe {
|
||||
// zero the memory
|
||||
memset(mem, 0, section.sh_size as usize);
|
||||
}
|
||||
section.sh_offset = mem.addr() as u64;
|
||||
}
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn elf_load_stage2(hdr: *const Elf64Ehdr) -> i8 {
|
||||
let shdr = unsafe { elf_sheader(hdr) } as *mut Elf64Shdr;
|
||||
let mut i: u16 = 0;
|
||||
let mut idx: u64;
|
||||
let shnum = unsafe { (*hdr).e_shnum };
|
||||
|
||||
while i < shnum {
|
||||
let section: &mut Elf64Shdr = unsafe { &mut *(shdr.add(i as usize)) };
|
||||
|
||||
if section.sh_type == SHT_REL {
|
||||
idx = 0;
|
||||
while idx < section.sh_size / section.sh_entsize {
|
||||
let reltab: *const Elf64Rel = unsafe {
|
||||
((hdr as *const u8).add(section.sh_offset as usize) as *const Elf64Rel)
|
||||
.add(idx as usize)
|
||||
};
|
||||
|
||||
let result: i8 = unsafe { elf_do_reloc(hdr, reltab, section) };
|
||||
|
||||
if result == -1 {
|
||||
return -1;
|
||||
}
|
||||
|
||||
idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user