All pastes #138993 Raw Edit

Someone

public c v1 · immutable
#138993 ·published 2006-08-19 16:14 UTC
rendered paste body
// in main.c:void main(uint_32 mbinfo_magic, uint_32 mbinfo_address){	gdt_install();	idt_install();	isrs_install();	irq_install();	video_init();	printf("Popcorn %s booting...\n", POPCORN_VERSION);	printf("Build %s.\n", POPCORN_BUILD);	multiboot_check(mbinfo_magic);	// point this to the address of mbinfo	multiboot_info_t *mbinfo = (multiboot_info_t *)mbinfo_address; 	debug("Multiboot flags: %b\n", mbinfo->flags);	uint_32 ram = (mbinfo->mem_lower + mbinfo->mem_upper) / 1024;	debug("Found %d MB RAM\n", ram);	mm_init(ram);	char *cmdline = (char *)mbinfo->cmdline;	debug("Kernel is %s, given %d arguments\n", strsplit(cmdline, ' ', 0), strnumtokens(cmdline, ' ') - 1);	if (CHECK_FLAG(mbinfo->flags, 3))	{		modules_init(mbinfo->mods_count, mbinfo->mods_addr);	}	else	{		modules_init(0, 0);	}	partition_info_t pi = find_boot_partition(0x66);	if (pfs_mount(pi.drive, pi.partnum, "/", true))		panic_msg("Couldn't mount root fs");	__asm__ __volatile__ ("sti");	timer_init();	keyboard_init();	// This is broken.	uint_8 buffer[8192];	pfs_read_file("/testfile", pi.drive, pi.partnum, 0, 0, &buffer[0]);	int i;	for (i = 0; i < 20; i++)		printf("%c", buffer[i]);	kbdemo();}// in pfs.c:void pfs_read_file(char *filename, uint_8 disk, uint_8 partition, uint_32 user, uint_32 group, uint_32 buffer_addr){	irq_install_handler(15, test);	pfs_dirblock_t thisdir;	pfs_read_block(1, disk, partition, &thisdir);	int i;	boolean found_it;	for (i = 0; i < 15; i++)	{		if (strcmp(strsplit(thisdir.files[i].name, ' ', 1), filename))		{			found_it = true;			break;		}	}	if (!found_it)	{		printf("Couldn't read %s (file not found)\n");		return;	}	// TODO: actually read in the next block...	// TODO: permission check	// TODO: support files not in /		pfs_block_t *fileblock = (pfs_block_t *)buffer_addr;	pfs_read_block(thisdir.files[i].first_block, disk, partition, buffer_addr);}