#include #include #include #include #include #include #include #include #include #include #include typedef struct { char filename[100]; char mode[8]; char uid[8]; char gid[8]; char size[12]; char mtime[12]; char chksum[8]; char typeflag[1]; } tar_header; size_t getsize(const char *in) { size_t size=0; size_t j; size_t count=1; for (j=11;j>0;j--,count*=8) { size+=((in[j-1]-'0')*count); } return size; } size_t find_loc(char* name,char* initrd) { size_t pos=0; 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;i0) { fseek(initrd,pheader.offset+datapos,SEEK_SET); fread(ptr,sizeof(char),pheader.filesz,initrd); } copy_data(address_space,ptr,pheader.memsz,(void*)pheader.vaddr); } create_proc((void*)header.entry,address_space,NULL,NULL); } return 1; } int main() { serial_print("Init running\n"); long size=initrd_sz(); char* initrd=malloc(size); initrd_get(initrd); size_t datapos=find_loc("vfs",initrd); load_proc(datapos,initrd); while(rpc_is_init(2)==0); datapos=find_loc("devfs",initrd); load_proc(datapos,initrd); while(rpc_is_init(3)==0); int err=mount("","devfs","/dev"); if (err) { serial_print("Failed to mount devfs\n"); exit(1); } datapos=find_loc("initrd_drv",initrd); load_proc(datapos,initrd); while(rpc_is_init(4)==0); serial_print("Loading VGA driver\n"); datapos=find_loc("vga_drv",initrd); load_proc_devfs(datapos); while(rpc_is_init(5)==0); serial_print("Opening /dev/vga\n"); stdout=fopen("/dev/vga","w"); if (!stdout) { serial_print("Could not open /dev/vga\n"); exit(1); } serial_print("Writing to screen\n"); puts("Puts test"); printf("Printf test with file opened to %s\n","/dev/vga"); }