Skip to content

Commit

Permalink
Allow adding and removal of driver partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcmaster-au committed May 29, 2014
1 parent 689eb73 commit 51b1a82
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions partition_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,25 @@ add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32
}
// renumber disk addresses
renumber_disk_addresses(map);
// mark changed

// Special processing for driver partitions
if (strstr(dptype, "Driver"))
{
// Assume 68k drivers for now
strncpy(cur->data->dpme_process_id, "68000", 5);

Block0* bz = map->misc;
if (bz->sbDrvrCount < sizeof(bz->sbMap) / sizeof(DDMap))
{
DDMap* ddmap = &((DDMap*)bz->sbMap)[bz->sbDrvrCount];
ddmap->ddBlock = base;
ddmap->ddSize = length;
ddmap->ddType = 1; // System type, 1 for Mac+
bz->sbDrvrCount++;
}
}

// mark changed
map->changed = 1;
return 1;
}
Expand Down Expand Up @@ -695,10 +713,27 @@ delete_partition_from_map(partition_map *entry)
printf("Can't delete entry for the map itself\n");
return;
}
if (contains_driver(entry)) {
printf("Can't delete entry for a driver (yet).\n");
return;

// Search for and remove driver references.
{
Block0* bz = entry->the_map->misc;
int i;
for (i = 0; i < bz->sbDrvrCount; ++i)
{
DDMap* ddmap = &((DDMap*)bz->sbMap)[i];
if (ddmap->ddBlock == entry->data->dpme_pblock_start)
{
// Found a driver!
memmove(
&((DDMap*)bz->sbMap)[i],
&((DDMap*)bz->sbMap)[i + 1],
(bz->sbDrvrCount - i - 1) * sizeof(DDMap));
bz->sbDrvrCount--;
break;
}
}
}

data = create_data(kFreeName, kFreeType,
entry->data->dpme_pblock_start, entry->data->dpme_pblocks);
if (data == NULL) {
Expand Down

0 comments on commit 51b1a82

Please sign in to comment.