luxos/Kernel/library/storage.c

19 lines
396 B
C

/*
* storage.c
*
* Created on: Aug 23, 2011
* Author: Tiberiu
*/
#include <storage.h>
void ConvertLbaToChs(uint32 SectorsPerTrack, uint32 lba, uint32 *cyl, uint32 *head, uint32 *sector)
{
// Avoid division by 0
if (SectorsPerTrack == 0) return;
*head = (lba % (SectorsPerTrack * 2)) / SectorsPerTrack;
*cyl = lba / (SectorsPerTrack * 2);
*sector = lba % SectorsPerTrack + 1;
}