1#include "part_driver.h"
11#include "module_debug.h"
19int GetNextFreePartitionIndex()
22 for (
int i = 0; i < MAX_PARTITIONS; i++)
24 if (g_part[i].bd == NULL)
37 M_DEBUG(
"%s\n", __func__);
39 for (i = 0; i < MAX_PARTITIONS; ++i) {
40 if (g_part[i].bd == bd) {
41 bdm_disconnect_bd(&g_part_bd[i]);
54 if ((part == NULL) || (part->bd == NULL))
58 u64 finalSector = sector + bd->sectorOffset;
59 DEBUG_U64_2XU32(finalSector);
60 M_DEBUG(
"%s (%s %d %d) 0x%08x%08x %d\n", __func__, bd->name, bd->devNr, bd->parNr, finalSector_u32[1], finalSector_u32[0],
count);
63 return part->bd->read(part->bd, sector + bd->sectorOffset, buffer,
count);
66static int part_write(
struct block_device *bd, u64 sector,
const void *buffer, u16
count)
70 if ((part == NULL) || (part->bd == NULL))
74 u64 finalSector = sector + bd->sectorOffset;
75 DEBUG_U64_2XU32(finalSector);
76 M_DEBUG(
"%s (%s %d %d) 0x%08x%08x %d\n", __func__, bd->name, bd->devNr, bd->parNr, finalSector_u32[1], finalSector_u32[0],
count);
79 return part->bd->write(part->bd, sector + bd->sectorOffset, buffer,
count);
86 M_DEBUG(
"%s\n", __func__);
88 if ((part == NULL) || (part->bd == NULL))
91 return part->bd->flush(part->bd);
98 M_DEBUG(
"%s\n", __func__);
100 if ((part == NULL) || (part->bd == NULL))
103 return part->bd->stop(part->bd);
110 M_DEBUG(
"%s\n", __func__);
112 for (i = 0; i < MAX_PARTITIONS; ++i) {
115 g_part_bd[i].priv = &g_part[i];
116 g_part_bd[i].read = part_read;
117 g_part_bd[i].write = part_write;
118 g_part_bd[i].flush = part_flush;
119 g_part_bd[i].stop = part_stop;
123 g_mbr_fs.priv = NULL;
124 g_mbr_fs.name =
"MBR";
125 g_mbr_fs.connect_bd = part_connect_mbr;
126 g_mbr_fs.disconnect_bd = part_disconnect;
127 bdm_connect_fs(&g_mbr_fs);
130 g_gpt_fs.priv = NULL;
131 g_gpt_fs.name =
"GPT";
132 g_gpt_fs.connect_bd = part_connect_gpt;
133 g_gpt_fs.disconnect_bd = part_disconnect;
134 bdm_connect_fs(&g_gpt_fs);
u32 count
start sector of fragmented bd/file