Exemple #1
0
/**
 * Extract the pointer to the NFILL/Gouraud record from the given DL object,
 * loading it from disk if needed.
 */
void *load_dldata(LISTOBJECT *lobj)
{
  switch ( lobj->opcode ) {
    case RENDER_fill:
      if ( (lobj->marker & MARKER_ONDISK) == 0 )
        return (void *)(lobj->dldata.nfill);
      else {
        size_t thd, info[2];
        uint8 *head = dl_load(info, sizeof(info), lobj);
        NFILLOBJECT *nfill;

        nfill = (NFILLOBJECT *)(head + info[1]);
        for ( thd = 0; thd < (size_t)nfill->nthreads; thd++ )
          nfill->thread[thd] = (NBRESS *)((char *)nfill -
                                          (char *)nfill->thread[thd]);
        return (void *)nfill;
      }
    case RENDER_gouraud:
      if ( (lobj->marker & MARKER_ONDISK) == 0 )
        return (void *)(lobj->dldata.gouraud);
      else {
        size_t info[1];
        uint8 *head = dl_load(info, sizeof(info), lobj);

        return (void *)head;
      }
    default:
      /* HQFAIL("Unexpected DL opcode to load from disk"); */
      /* return NULL; */
      return (void *)(lobj->dldata.nfill);
  }
}
Exemple #2
0
int main() {
	struct tar_file *boot_image, *file;
	char const **argv;
	uint64_t temp, temp1, temp2;

	argv = malloc(sizeof(char*) * 4);

	/* Boot Image */
	boot_image = tar_parse((void*) BOOT_IMAGE);

	/* Dynamic Linker */
	file = tar_find(boot_image, "lib/dl.so");
	dl_load(file->start);

	/* Initial Root Filesystem / Device Filesystem / System Filesystem (tmpfs) */
	argv[0] = "tmpfs";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/tmpfs");
	fs_root = start(file, argv);
	io_cons("/dev", RP_TYPE_DIR);
	io_cons("/sys", RP_TYPE_DIR);

	/* Logfile */
	io_cons("/dev/stderr", RP_TYPE_FILE);

	/* Init control file */
	io_link("/sys/init", RP_CONS(getpid(), 1));

	/* Keyboard Driver */
	argv[0] = "kbd";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/kbd");
	temp = start(file, argv);

	/* Terminal Driver */
	argv[0] = "tty";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/tty");
	temp = start(file, argv);
	io_link("/dev/tty", temp);

	/* Splash */
	stdin = stderr = stdout = fopen("/dev/tty", "w");
	printf(splash);

	/* Initrd */
	initrd_init();
	io_link("/dev/initrd", RP_CONS(getpid(), 0));

	/* Root filesystem (tarfs) */
	argv[0] = "tarfs";
	argv[1] = "/dev/initrd";
	argv[2] = NULL;
	file = tar_find(boot_image, "sbin/tarfs");
	temp = start(file, argv);

	/* Link /dev and /sys and change root */
	temp1 = io_find("/dev");
	temp2 = io_find("/sys");
	fs_root = temp;
	io_link("/dev", temp1);
	io_link("/sys", temp2);

	/* Temporary filesystem */
	argv[0] = "tmpfs";
	argv[1] = NULL;	
	file = tar_find(boot_image, "sbin/tmpfs");
	io_link("/tmp", start(file, argv));

	/* Time Driver */
	argv[0] = "time";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/time");
	io_link("/dev/time", start(file, argv));

	/* Serial Driver */
	argv[0] = "serial";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/serial");
	io_link("/dev/serial", start(file, argv));

	/* Path */
	setenv("PATH", "/bin");

	/* Flux Init Shell */
	argv[0] = "fish";
	argv[1] = NULL;
	file = tar_find(boot_image, "bin/fish");
	if (!file) {
		printf("critical error: no init shell found\n");
		for(;;);
	}

	if (fork() < 0) {
//		setcuser(1);
		execiv(file->start, file->size, argv);
	}

	setenv("NAME", "init");
	
	mwait(PORT_CHILD, 0);

	printf("INIT PANIC: system daemon died\n");
	for(;;);
	return 0;
}
Exemple #3
0
int main() {
	struct tar_file *boot_image, *file;
	char const **argv;
	uint64_t temp, temp1, temp2;

	argv = malloc(sizeof(char*) * 4);

	/* Boot Image */
	boot_image = tar_parse((void*) BOOT_IMAGE);

	/* Dynamic Linker */
	file = tar_find(boot_image, "lib/dl.so");
	dl_load(file->start);

	/* Initial Root Filesystem / Device Filesystem / System Filesystem (tmpfs) */
	argv[0] = "tmpfs";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/tmpfs");
	fs_root = start(file, argv);
	fs_cons("/dev", "dir");
	fs_cons("/sys", "dir");
	
	/* Serial Driver */
	argv[0] = "serial";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/serial");
	fs_plink("/dev/serial", start(file, argv), NULL);
	ropen(1, fs_find("/dev/serial"), STAT_WRITER);
	ropen(2, fs_find("/dev/serial"), STAT_WRITER);
	stdout = fdopen(1, "w");
	stderr = fdopen(2, "w");

	fs_plink("/dev/stderr", fs_find("/dev/serial"), NULL);

	/* Keyboard Driver */
	argv[0] = "kbd";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/kbd");
	temp = start(file, argv);

	/* Graphics Driver */
	argv[0] = "svga";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/svga");
	start(file, argv);

	/* Init control file */
	fs_plink("/sys/init", RP_CONS(getpid(), 0), NULL);

	/* Initrd */
	initrd_init();
	fs_plink("/dev/initrd", RP_CONS(getpid(), 1), NULL);

	/* Root filesystem (tarfs) */
	argv[0] = "tarfs";
	argv[1] = "/dev/initrd";
	argv[2] = NULL;
	file = tar_find(boot_image, "sbin/tarfs");
	temp = start(file, argv);

	/* Link /dev and /sys and change root */
	temp1 = fs_find("/dev");
	temp2 = fs_find("/sys");
	fs_root = temp;
	fs_plink("/dev", temp1, NULL);
	fs_plink("/sys", temp2, NULL);

	/* Terminal Driver */
	argv[0] = "biterm";
	argv[1] = "/dev/kbd";
	argv[2] = "/dev/svga0";
	argv[3] = NULL;
	file = tar_find(boot_image, "sbin/biterm");
	fs_plink("/dev/tty", start(file, argv), NULL);

	/* Temporary filesystem */
	argv[0] = "tmpfs";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/tmpfs");
	fs_plink("/tmp", start(file, argv), NULL);

	/* Time Driver */
	argv[0] = "time";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/time");
	fs_plink("/dev/time", start(file, argv), NULL);

	/* Pipe Driver */
	argv[0] = "pipe";
	argv[1] = NULL;
	file = tar_find(boot_image, "sbin/pipe");
	fs_plink("/sys/pipe", start(file, argv), NULL);

	setname("init");
	
	mwait(PORT_CHILD, 0);

	printf("INIT PANIC: system daemon died\n");
	for(;;);
	return 0;
}