|
Contiki-Inga 3.x
|
Files | |
| file | mbr.c |
MBR Support implementation | |
| file | mbr.h |
MBR Support definitions | |
Data Structures | |
| struct | mbr_primary_partition |
| Represents a primary partition in the mbr. More... | |
| struct | mbr |
| Represents the MBR of a disk, without the code portion and the constant bytes. More... | |
Functions | |
| void | mbr_init (struct mbr *mbr) |
| Initializes a mbr structure. More... | |
| int | mbr_read (struct diskio_device_info *from, struct mbr *to) |
| Reads the MBR from the specified device. More... | |
| int | mbr_write (struct mbr *from, struct diskio_device_info *to) |
| Write the MBR to the specified device. More... | |
| int | mbr_addPartition (struct mbr *mbr, uint8_t part_num, uint8_t part_type, uint32_t start, uint32_t len) |
| Adds a Partition to the mbr-structure. More... | |
| int | mbr_delPartition (struct mbr *mbr, uint8_t part_num) |
| Deletes a Partition from the mbr-structure. More... | |
| int | mbr_hasPartition (struct mbr *mbr, uint8_t part_num) |
| Checks if the given Partition exists. More... | |
Variables | |
| uint8_t | mbr_primary_partition::status |
| 0x00 non-bootable, 0x80 bootable, other values indicate that it is invalid | |
| uint8_t | mbr_primary_partition::chs_first_sector [3] |
| Saves the first sector of the partition in the old CHS format (cylinder, head, sector) More... | |
| uint8_t | mbr_primary_partition::type |
| The type of partition this is, like FAT16 or FAT32; type = 0 means it's unused. | |
| uint8_t | mbr_primary_partition::chs_last_sector [3] |
| Stores the last sector of the partition in the old CHS format. | |
| uint32_t | mbr_primary_partition::lba_first_sector |
| Stores the absolute address of the first sector of the partition. | |
| uint32_t | mbr_primary_partition::lba_num_sectors |
| Stores the number of sectors the partition is long. | |
| struct mbr_primary_partition | mbr::partition [4] |
| The MBR supports max 4 Primary partitions. More... | |
| int mbr_addPartition | ( | struct mbr * | mbr, |
| uint8_t | part_num, | ||
| uint8_t | part_type, | ||
| uint32_t | start, | ||
| uint32_t | len | ||
| ) |
Adds a Partition to the mbr-structure.
| *mbr | The mbr-structure in which to insert the partition. |
| part_num | Number of the Partition which should be added. |
| part_type | Type of the partition. |
| start | LBA-style start of the partition. |
| len | LBA-style length of the partition. |
Definition at line 101 of file mbr.c.
References mbr_primary_partition::chs_first_sector, mbr_primary_partition::chs_last_sector, mbr_primary_partition::lba_first_sector, mbr_primary_partition::lba_num_sectors, mbr_hasPartition(), mbr::partition, mbr_primary_partition::status, and mbr_primary_partition::type.
| int mbr_delPartition | ( | struct mbr * | mbr, |
| uint8_t | part_num | ||
| ) |
Deletes a Partition from the mbr-structure.
| *mbr | The mbr-structure which should be edited. |
| part_num | Number of the partition which should be removed. |
Definition at line 140 of file mbr.c.
References mbr::partition, and mbr_primary_partition::status.
| int mbr_hasPartition | ( | struct mbr * | mbr, |
| uint8_t | part_num | ||
| ) |
Checks if the given Partition exists.
| part_num | Number of the Partition which should be checked. |
Definition at line 154 of file mbr.c.
References mbr::partition, mbr_primary_partition::status, and mbr_primary_partition::type.
Referenced by diskio_detect_devices(), and mbr_addPartition().
| void mbr_init | ( | struct mbr * | mbr | ) |
Initializes a mbr structure.
Should be called first on a new mbr structure.
| *mbr | the mbr which should be initialized |
| disk_size | the size of the disk on which the mbr will reside |
Definition at line 51 of file mbr.c.
References mbr::partition, and mbr_primary_partition::status.
Referenced by diskio_detect_devices().
| int mbr_read | ( | struct diskio_device_info * | from, |
| struct mbr * | to | ||
| ) |
Reads the MBR from the specified device.
The MBR is 512 Bytes long. That is normally one block to be read.
| *from | device from which the mbr is read |
| *to | whe mbr structure in which the data is parsed |
Definition at line 62 of file mbr.c.
References diskio_read_block(), and mbr::partition.
Referenced by diskio_detect_devices().
| int mbr_write | ( | struct mbr * | from, |
| struct diskio_device_info * | to | ||
| ) |
Write the MBR to the specified device.
| *from | the mbr structure which should be written on the device |
| *to | the device pointer to which we will write the mbr |
Definition at line 84 of file mbr.c.
References diskio_write_block(), and mbr::partition.
| uint8_t mbr_primary_partition::chs_first_sector[3] |
Saves the first sector of the partition in the old CHS format (cylinder, head, sector)
First byte stores the head value. Second byte stores the sector in the positions 0 - 5 and the upper to bits of the cylinder (Bits 8 and 9) Third byte stores the lower 8 bits of the cylinder value (0 - 7)
Definition at line 77 of file mbr.h.
Referenced by mbr_addPartition().
| struct mbr_primary_partition mbr::partition[4] |
The MBR supports max 4 Primary partitions.
For the sake of simplicity Extended partitions are not implemented.
Definition at line 95 of file mbr.h.
Referenced by diskio_detect_devices(), mbr_addPartition(), mbr_delPartition(), mbr_hasPartition(), mbr_init(), mbr_read(), and mbr_write().
1.8.3.1