os/init/main.c

53 lines
1.0 KiB
C
Raw Normal View History

#include <string.h>
2019-05-05 07:31:13 -05:00
#include "vga.h"
2019-05-03 08:34:22 -05:00
#include <grub/text_fb_info.h>
2019-05-01 09:39:23 -05:00
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;
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;
}
int main(char* initrd, uint32_t initrd_sz) {
2019-05-03 08:34:22 -05:00
text_fb_info info;
2019-05-23 17:08:03 -05:00
info.address=map_phys(0xB8000,10);
2019-05-03 08:34:22 -05:00
info.width=80;
info.height=25;
vga_init(info);
vga_write_string("INIT VGA\n");
int pos=0;
tar_header hdr;
for (int i=0;;i++) {
char* hdr_ptr=(char*)&hdr;
for (size_t i=0;i<sizeof(tar_header);i++) {
hdr_ptr[i]=initrd[pos+i];
}
if (hdr.filename[0]=='\0') break;
uint32_t size=getsize(hdr.size);
pos+=512;
if (strcmp(hdr.filename,"vfs")==0) {
vga_write_string("VFS found");
}
pos+=size;
if (pos%512!=0) {
pos+=512-(pos%512);
}
}
2019-05-01 19:42:46 -05:00
for (;;);
2019-03-17 18:04:50 -05:00
}