diff --git a/tpfs/Makefile b/tpfs/Makefile index 393143bb39836099b6e067e0fd469f68492094e4..bbe3d0272ea94f129eca9ee5cace3955410cf4fe 100644 --- a/tpfs/Makefile +++ b/tpfs/Makefile @@ -13,7 +13,7 @@ LIBS = -L$(LIBDIR) -lhardware ###------------------------------ ### Main targets ###------------------------------------------------------------ -BINARIES= mkhd display_sector format_sector write_sector mkvol +BINARIES= mkhd display_sector format_sector write_sector mkvol dvol all: $(BINARIES) $(OBJECTS) @@ -32,6 +32,7 @@ display_sector: display_sector.o drive.o format_sector: format_sector.o drive.o write_sector: write_sector.o drive.o mkvol: mkvol.o vol.o drive.o +dvol: dvol.o vol.o drive.o ###------------------------------ ### Misc. diff --git a/tpfs/drive.c b/tpfs/drive.c index 92ed94281a1009bdcb504a489c8d9a8b7c55647d..63df074730143e61529d1afe53ff39079effc4dd 100644 --- a/tpfs/drive.c +++ b/tpfs/drive.c @@ -68,6 +68,15 @@ void read_sector(unsigned char *buf, int cylinder, int sector) buf[i] = MASTERBUFFER[i]; } +void read_sector_n(unsigned char *buf, int cylinder, int sector, int size) +{ + int i; + unsigned char buffer[HDA_SECTORSIZE]; + read_sector(buffer, cylinder, sector); + for (i = 0; i < size; i++) + buf[i] = buffer[i]; +} + void write_sector(unsigned int cylinder, unsigned int sector, unsigned char *buf) { int i; diff --git a/tpfs/drive.h b/tpfs/drive.h index 927499bcb96aec804f9de78f836dcca738e531b8..556c9c0e6c7794f443258a39b728d17dca74d0f8 100644 --- a/tpfs/drive.h +++ b/tpfs/drive.h @@ -16,6 +16,7 @@ void dump(unsigned char *buffer, int octal_dump); void seek(int cylinder, int sec); void read_sector(unsigned char *buf, int cylinder, int sector); +void read_sector_n(unsigned char *buf, int cylinder, int sector, int size); void write_sector(unsigned int cylinder, unsigned int sector, unsigned char *buf); void format_sector(unsigned int cylinder, unsigned int sector, diff --git a/tpfs/dvol.c b/tpfs/dvol.c new file mode 100644 index 0000000000000000000000000000000000000000..335f6c32cb2de1fe362ed9697b7fb5048715c3a3 --- /dev/null +++ b/tpfs/dvol.c @@ -0,0 +1,60 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "hardware.h" +#include "vol.h" + +void display_vol() +{ + int vol; + char *vtype_names[3] = {"BASE", "ANNEXE", "OTHER"}; + vol_t volume; + + if (mbr.nb_vols == 0) + { + printf("Il n'y aucun volume.\n"); + return; + } + + printf("--------------------------\n"); + for (vol = 0; vol < mbr.nb_vols; vol++) + { + volume = mbr.vols[vol]; + printf("Volume: %d (%s)\n", vol, vtype_names[volume.type]); + printf("> Sector: %d \n", volume.sector); + printf("> Cylinder: %d \n", volume.cylinder); + printf("> Nb blocs: %d \n", volume.nb_blocs); + printf("--------------------------\n"); + } +} + +static void +empty_it() +{ + return; +} + +int main(int argc, char const *argv[]) +{ + unsigned int i; + + /* init hardware */ + if (init_hardware("hwconfig.ini") == 0) + { + fprintf(stderr, "Error in hardware initialization\n"); + exit(EXIT_FAILURE); + } + + /* Interreupt handlers */ + for (i = 0; i < 16; i++) + IRQVECTOR[i] = empty_it; + + /* Allows all IT */ + _mask(1); + + load_mbr(); + display_vol(); + + /* and exit! */ + exit(EXIT_SUCCESS); +} diff --git a/tpfs/vol.c b/tpfs/vol.c index 4386aa2d08418196c0c95e3b58c9ee4d707bea4b..935fcdc4a2d97d465d69fd15f0c457cbd5ae6ce2 100644 --- a/tpfs/vol.c +++ b/tpfs/vol.c @@ -90,13 +90,4 @@ void format_vol(unsigned int vol) get_sector_cylinder(vol, nbloc, sector_cylinder); /* [sector, cylinder] */ format_sector(sector_cylinder[1], sector_cylinder[1], FMT_SIZE, FMT_DATA); } -} - -void read_sector_n(unsigned char *buf, int cylinder, int sector, int size) -{ - int i; - unsigned char buffer[HDA_SECTORSIZE]; - read_sector(buffer, cylinder, sector); - for (i = 0; i < size; i++) - buf[i] = buffer[i]; } \ No newline at end of file