Lines Matching refs:diskinfo

74 int disk_get_params(int disk, struct disk_info *const diskinfo)  in disk_get_params()  argument
80 memset(diskinfo, 0, sizeof *diskinfo); in disk_get_params()
81 diskinfo->disk = disk; in disk_get_params()
82 diskinfo->bps = SECTOR; in disk_get_params()
95 diskinfo->ebios = 1; in disk_get_params()
103 if (diskinfo->ebios) { in disk_get_params()
116 diskinfo->lbacnt = eparam->lbacnt; in disk_get_params()
118 diskinfo->bps = eparam->bps; in disk_get_params()
137 rv = diskinfo->ebios ? 0 : -1; in disk_get_params()
141 diskinfo->spt = 0x3f & outreg.ecx.b[0]; in disk_get_params()
142 diskinfo->head = 1 + outreg.edx.b[1]; in disk_get_params()
143 diskinfo->cyl = 1 + (outreg.ecx.b[1] | ((outreg.ecx.b[0] & 0xc0u) << 2)); in disk_get_params()
145 if (diskinfo->spt) in disk_get_params()
146 diskinfo->cbios = 1; /* Valid geometry */ in disk_get_params()
148 diskinfo->head = 1; in disk_get_params()
149 diskinfo->spt = 1; in disk_get_params()
150 diskinfo->cyl = 1; in disk_get_params()
153 if (!diskinfo->lbacnt) in disk_get_params()
154 diskinfo->lbacnt = diskinfo->cyl * diskinfo->head * diskinfo->spt; in disk_get_params()
171 static void *ebios_setup(const struct disk_info *const diskinfo, com32sys_t *inreg, in ebios_setup() argument
183 buf = lmalloc(count * diskinfo->bps); in ebios_setup()
196 inreg->edx.b[0] = diskinfo->disk; in ebios_setup()
211 static void *chs_setup(const struct disk_info *const diskinfo, com32sys_t *inreg, in chs_setup() argument
217 buf = lmalloc(count * diskinfo->bps); in chs_setup()
227 s = lba % diskinfo->spt; in chs_setup()
228 t = lba / diskinfo->spt; in chs_setup()
229 h = t % diskinfo->head; in chs_setup()
230 c = t / diskinfo->head; in chs_setup()
238 inreg->edx.b[0] = diskinfo->disk; in chs_setup()
256 void *disk_read_sectors(const struct disk_info *const diskinfo, uint64_t lba, in disk_read_sectors() argument
265 maxcnt = (size - diskinfo->bps) / diskinfo->bps; in disk_read_sectors()
266 if (!count || count > maxcnt || lba + count > diskinfo->lbacnt) in disk_read_sectors()
271 if (diskinfo->ebios) in disk_read_sectors()
272 buf = ebios_setup(diskinfo, &inreg, lba, count, EBIOS_READ_CODE); in disk_read_sectors()
274 buf = chs_setup(diskinfo, &inreg, lba, count, CHS_READ_CODE); in disk_read_sectors()
282 data = malloc(count * diskinfo->bps); in disk_read_sectors()
284 memcpy(data, buf, count * diskinfo->bps); in disk_read_sectors()
302 int disk_write_sectors(const struct disk_info *const diskinfo, uint64_t lba, in disk_write_sectors() argument
311 maxcnt = (size - diskinfo->bps) / diskinfo->bps; in disk_write_sectors()
312 if (!count || count > maxcnt || lba + count > diskinfo->lbacnt) in disk_write_sectors()
317 if (diskinfo->ebios) in disk_write_sectors()
318 buf = ebios_setup(diskinfo, &inreg, lba, count, EBIOS_WRITE_CODE); in disk_write_sectors()
320 buf = chs_setup(diskinfo, &inreg, lba, count, CHS_WRITE_CODE); in disk_write_sectors()
325 memcpy(buf, data, count * diskinfo->bps); in disk_write_sectors()
349 int disk_write_verify_sectors(const struct disk_info *const diskinfo, in disk_write_verify_sectors() argument
355 rv = disk_write_sectors(diskinfo, lba, buf, count); in disk_write_verify_sectors()
358 rb = disk_read_sectors(diskinfo, lba, count); in disk_write_verify_sectors()
361 rv = memcmp(buf, rb, count * diskinfo->bps); in disk_write_verify_sectors()