Skip to content
Snippets Groups Projects
Commit 06131deb authored by Thierno souleymane Bah's avatar Thierno souleymane Bah
Browse files

feat(load_mdr function implemented)

parent 3b5fa1b2
Branches
No related tags found
No related merge requests found
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include "hardware.h"
#include "drive.h"
#include "vol.h"
void load_mbr()
{
int i;
unsigned char buffer[sizeof(mbr_t)];
read_sector(buffer, 0, 0);
mbr.magic = buffer[0] + (buffer[1] << 8);
if (mbr.magic == MBR_MAGIC)
{
mbr.nb_vols = buffer[2];
for (i = 0; i < mbr.nb_vols; i++)
{
mbr.vols[i].sector = buffer[3 + (i * 4)];
mbr.vols[i].cylinder = buffer[4 + (i * 4)];
mbr.vols[i].nb_sectors = buffer[5 + (i * 4)];
mbr.vols[i].type = buffer[6 + (i * 4)];
}
return;
}
mbr.magic = MBR_MAGIC;
mbr.nb_vols = 0;
}
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define VOL_H #define VOL_H
#define NB_VOLS_MAX 8 #define NB_VOLS_MAX 8
#define MBR_MAGIC 0xCAFE // Savoir si le mbr a déjà été initialisé ou non
static mbr_t mbr; static mbr_t mbr;
...@@ -22,6 +23,7 @@ typedef struct vol_s ...@@ -22,6 +23,7 @@ typedef struct vol_s
typedef struct mbr_s typedef struct mbr_s
{ {
unsigned int magic;
unsigned int nb_vols; // nombre de volumes actuels unsigned int nb_vols; // nombre de volumes actuels
vol_t vols[NB_VOLS_MAX]; vol_t vols[NB_VOLS_MAX];
} mbr_t; } mbr_t;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment