#include #include #include #include #include #include #include #include "cpu/cpu_init.h" #include "vga_err.h" #include typedef struct { char filename[100]; char mode[8]; char uid[6]; char gid[8]; char size[12]; char mtime[12]; char chksum[8]; char typeflag[1]; } tar_header; static long initrd_sz; static char* initrd; typedef int (*func_ptr)(); static struct multiboot_boot_header_tag* tags; static void read_initrd(struct multiboot_boot_header_tag* tags) { struct multiboot_tag* tag=(struct multiboot_tag*)(tags+1); while (tag->type!=0) { switch (tag->type) { case MULTIBOOT_TAG_TYPE_MODULE: { struct multiboot_tag_module* mod=(struct multiboot_tag_module*) tag; initrd=malloc(sizeof(char)*(mod->mod_end-mod->mod_start)); initrd_sz=mod->mod_end-mod->mod_start; memcpy(initrd,(void*)(mod->mod_start+0xC0000000),mod->mod_end-mod->mod_start); } } tag=(struct multiboot_tag*)((char*)tag+((tag->size+7)&0xFFFFFFF8)); } } uint32_t getsize(const char *in) { uint32_t size=0; uint32_t j; uint32_t count=1; for (j=11;j>0;j--,count*=8) { size+=((in[j-1]-'0')*count); } return size; } void kmain(struct multiboot_boot_header_tag* hdr) { tags=hdr; cpu_init(tags); vga_init((char*)0xC00B8000); read_initrd(tags); int pos=0; uint32_t datapos; tar_header tar_hdr; for (int i=0;;i++) { char* tar_hdr_ptr=(char*)&tar_hdr; for (size_t i=0;i0) { pos=pheader.offset+datapos; for (size_t i=0;i