Misc stuff

This commit is contained in:
mintsuki 2020-03-25 05:19:07 +01:00
parent f762a0c7a3
commit 1b80c8ca90
3 changed files with 8 additions and 9 deletions

View File

@ -16,7 +16,7 @@ struct echfs_identity_table {
#define END_OF_CHAIN (~((uint64_t)0))
#define FILE_TYPE 0
#define CACHE_ADDR ((uint8_t *)(0x1000000))
#define CACHE_ADDR ((uint8_t *)(0x20000))
static int cache_block(struct echfs_file_handle *file, uint64_t block) {
// Load the file.

View File

@ -1,6 +1,5 @@
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <lib/blib.h>
#include <lib/libc.h>
#include <lib/elf.h>
@ -50,8 +49,6 @@ struct elf_phdr {
#define FIXED_HIGHER_HALF_OFFSET ((uint64_t)0xffffffff80000000)
int elf_load(struct echfs_file_handle *fd) {
bool elf_higher_half = false;
struct elf_hdr hdr;
echfs_read(fd, &hdr, 0, sizeof(struct elf_hdr));
@ -78,11 +75,8 @@ int elf_load(struct echfs_file_handle *fd) {
if (phdr.p_type != PT_LOAD)
continue;
if (phdr.p_vaddr & (1ull << 63)) {
print("elf: This is a higher half kernel!\n");
elf_higher_half = true;
if (phdr.p_vaddr & (1ull << 63))
phdr.p_vaddr -= FIXED_HIGHER_HALF_OFFSET;
}
echfs_read(fd, (void *)(uint32_t)phdr.p_vaddr,
phdr.p_offset, phdr.p_filesz);

View File

@ -9,5 +9,10 @@ section .text
global _start
_start:
mov rax, 0xcafebabedeadbeef
mov rax, 'h e l l '
mov rbx, 'o w o '
mov rcx, 'r l d '
mov [0xb8000], rax
mov [0xb8008], rbx
mov [0xb8010], rcx
jmp $