25static void apaCalculateFreeSpace(u32 *free, u32 sectors)
27 if(0x1FFFFF < sectors)
33 if((*free & sectors) == 0)
39 for(sectors /= 2; 0x3FFFF < sectors; sectors /= 2)
43int apaGetFreeSectors(s32 device, u32 *free,
apa_device_t *deviceinfo)
51 if((clink = apaCacheGetHeader(device, APA_SECTOR_MBR, APA_IO_MODE_READ, &rv)) != NULL)
54 if(clink->header->type == 0)
55 apaCalculateFreeSpace(free, clink->header->length);
56 sectors += clink->header->length;
57 }
while((clink = apaGetNextHeader(clink, &rv)) != NULL);
62 for(partMax = deviceinfo[device].partitionMaxSize; 0x0003FFFF < partMax; partMax = deviceinfo[device].partitionMaxSize)
64 for( ; 0x0003FFFF < partMax; partMax /= 2)
67 if((sectors % partMax == 0) && ((u64)sectors + partMax < deviceinfo[device].totalLBA))
69 apaCalculateFreeSpace(free, partMax);
75 if(0x0003FFFF >= partMax)
79 APA_PRINTF(APA_DRV_NAME
": total = %08lx sectors, installable = %08lx sectors.\n", sectors, *free);