Example #1
0
static uval
launch_partition(struct partition_status *ps, struct load_file_entry* lf,
		 uval ofd)
{
	uval ret[1];
	uval rc;
	const uval defslot = 0x1;
	uval schedvals[3];
	sval rot;

	uval magic = lf->loaderSegmentTable[0].file_start;
	magic += 0x10;

	if (*(uval64*)magic == HYPE_PARTITION_INFO_MAGIC_NUMBER) {
		magic = *((uval*)(magic + 8));
	} else {
		magic = INVALID_LOGICAL_ADDRESS;
	}

	hputs("Creating partition\n");
	rc = hcall_create_partition(ret, ps->init_mem, ps->init_mem_size,
				    magic);
	assert(rc == H_Success,
	       "hcall_create_partition() failed rc= 0x%lx\n", rc);

	hprintf("Created partition  ID %ld\n"
		"  starting it @ pc = 0x%llx.\n",
		ret[0], lf->va_entry);
	ps->lpid = ret[0];

	vty_setup(ps);

	rot = hcall_set_sched_params(schedvals, ps->lpid,
				     THIS_CPU, defslot, 0);
	assert(rot >= 0, "set_sched failed\n");
	hprintf("Scheduled 0x%lx: rot: %ld (0x%016lx, 0x%016lx 0x%016lx)\n",
		ps->lpid, rot, schedvals[0], schedvals[1], schedvals[2]);


	curslots = schedvals[0];
	ps->slot = schedvals[2];

	register_partition(ps, ofd);

	if (!start_partition(ps, lf, ofd)) {
		return 0;
	}

	hprintf("%s: yielding to sysId: 0x%lx now\n", __func__, ps->lpid);
	hcall_yield(NULL, ps->lpid);
	hprintf("%s: back from yielding to sysId: 0x%lx\n",
		__func__, ps->lpid);


	return ps->lpid;
}
Example #2
0
errno_t phantom_register_disk_drive(phantom_disk_partition_t *p)
{
    assert( p->specific != 0 );
    assert( p->shift == 0 );
    assert( p->size != 0 );
    assert( p->base == 0 );

    // Temp! Rewrite!
    assert( p->block_size == 512 );

    //p->flags |= PART_FLAG_IS_WHOLE_DISK;
    assert( p->flags & PART_FLAG_IS_WHOLE_DISK );

    register_partition( p );
    // todo check sanity - no partitions overlap on each level

    return 0;
}
Example #3
0
static void lookup_old_pc_partitions(phantom_disk_partition_t *p)
{
    unsigned char buf[512];

    int lookAt =
        (p->flags & PART_FLAG_IS_WHOLE_DISK) ||
        (p->type == 0x05) ||
        (p->type == 0x0F) ||
        (p->type == 0x85);

    if(!lookAt ) return;

    //p->syncRead( p, buf, 0, 1 );
    if( phantom_sync_read_sector( p, buf, 0, 1 ))
        return;

    //hexdump(buf, 512, "", 0);


    //SHOW_FLOW0( 1, "Got block 0" );
    if( debug_level_flow > 10) hexdump( buf, sizeof(buf), "", 0);

    if( (buf[0x1FE] != 0x55) || (buf[0x1FF] != 0xAA) )
    {
        SHOW_ERROR0( 1, "No part table magic" );
        return;
    }

    SHOW_FLOW0( 1, "Has part table magic!" );

    p->flags |= PART_FLAG_IS_DIVIDED;

    int i; int pno = 0;
    for( i = 0x1BE; i <= 0x1EE; i += 16, pno++ )
    {
        struct pc_partition *pp = (struct pc_partition *)(buf+i);

        SHOW_FLOW( 2, "Check partition %d, start %d, size %d, type 0x%02X", pno, pp->start, pp->size, pp->type );

        if(pp->size == 0)
            continue; // break?

        phantom_disk_partition_t * newp = phantom_create_partition_struct( p, pp->start, pp->size );
        newp->type = pp->type;


        if(newp->type == PHANTOM_PARTITION_TYPE_ID)
        {
            printf("!! Phantom Partition found !!\n");
            p->flags |= PART_FLAG_IS_PHANTOM_TYPE;

        }

        char pn[4] = "PC0";
        //pn[2] += pno++;
        pn[2] += pno;
        strncpy(newp->name, pn, PARTITION_NAME_LEN-1);

        register_partition( newp );
    }

}