diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.h | 4 | ||||
-rw-r--r-- | src/features/elf.c | 18 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/test.c | 5 |
4 files changed, 12 insertions, 17 deletions
diff --git a/src/config.h b/src/config.h index 4d8f5ce..29c0e23 100644 --- a/src/config.h +++ b/src/config.h @@ -7,8 +7,8 @@ int MELVIX_VERSION = 0; #define USERNAME "Neo" -#define FONT_PATH "/font/ter-p32n.psf" -//#define FONT_PATH "/font/spleen-16x32.psfu" +//#define FONT_PATH "/font/ter-p32n.psf" +#define FONT_PATH "/font/spleen-16x32.psfu" #define NETWORK "rtl8139" #endif diff --git a/src/features/elf.c b/src/features/elf.c index 339add0..f92f399 100644 --- a/src/features/elf.c +++ b/src/features/elf.c @@ -3,16 +3,13 @@ #include <elf.h> #include <fs.h> #include <mem.h> +#include <str.h> -int elf_verify(struct elf_header *header) +int elf_verify(struct elf_header *h) { - if (header->ident[0] == ELF_MAG && header->ident[1] == 'E' && header->ident[2] == 'L' && - header->ident[3] == 'F' && header->ident[4] == ELF_32 && - header->ident[5] == ELF_LITTLE && header->ident[6] == ELF_CURRENT && - header->machine == ELF_386 && (header->type == ET_REL || header->type == ET_EXEC)) { - return 1; - } - return 0; + return (h->ident[0] == ELF_MAG && !strncmp((char *)&h->ident[1], "ELF", 3) && + h->ident[4] == ELF_32 && h->ident[5] == ELF_LITTLE && h->ident[6] == ELF_CURRENT && + h->machine == ELF_386 && (h->type == ET_REL || h->type == ET_EXEC)); } void elf_load(char *path) @@ -28,7 +25,10 @@ void elf_load(char *path) u32 offset = (p->vaddr - p->paddr); while (p < p_end) { - memcpy((void *)p->paddr, (void *)((u32)data + p->offset), p->filesz); + printf("\nheader: 0x%x\n", p->paddr); + printf("filesz: %d\n", p->filesz); + /* memcpy(p->paddr, (u32)data + p->offset, p->filesz); */ + memcpy((u32 *)p->paddr, (u32 *)((u32)data + p->offset), p->filesz); p++; } @@ -42,7 +42,7 @@ void main(struct mem_info *mem_info, struct vid_info *vid_info) gui_init(FONT_PATH); gui_term_write("Wake up, " USERNAME "...\n"); - elf_load("/test.o"); + elf_load("/test"); printf("loaded"); while (1) { diff --git a/src/test.c b/src/test.c deleted file mode 100644 index c0f214b..0000000 --- a/src/test.c +++ /dev/null @@ -1,5 +0,0 @@ -void main() -{ - while (1) { - } -} |