diff options
| author | Jake Mannens <jake72360@gmail.com> | 2018-12-23 17:22:14 +1100 |
|---|---|---|
| committer | Jake Mannens <jake72360@gmail.com> | 2018-12-23 17:22:14 +1100 |
| commit | ce91afe04bd24fe9277a3f7b68ddf0654f1634ac (patch) | |
| tree | 428ca2ee2ca73e5c24c45c724178d2cdc9320c4d /include/kernel | |
| parent | a8a4f0710210ed91097a30fc26308c50be73d4de (diff) | |
Corrected a bug in the hard-disk driver where calls to hd_read_block()
after hd_init() failed (on a system without a disk), would hang. Now,
hd_read_block() will fail if no hard disk is present on the system (as
indicated by the nblocks count being equal to zero). The same fix also
applies to the hd_write_block() function.
The hd_init() function now returns a status indicating either successful
drive detection and initialization, or failure. This return status won't
likely be needed due to the above bug-fix, but may prove useful in the
future.
Added framework for a block buffer subsystem. This subsystem uses
pre-allocated memory to cache blocks that are requested from the block
device subsystem. Cached blocks are stored on a linked list sorted in
order of usage frequency.
Modified the block read/write functions so that they no longer accept a
length parameter. The block I/O functions will only read or write a
single block at a time. If multiple blocks are required, multiple calls
will have to be made. This is to reduce complexity of block device
drivers and make integration with the new buffer subsystem easier.
Removed all calls to the ATA hard-disk driver. For now, it seems that
floppy media will be best as it allows for real-world hardware testing.
Furthermore, large portions of the hard-disk driver will need to be
re-written anyway once the block buffer subsystem is complete as it only
supports PIO transfers, whilst a buffer system will require DMA
transfers. As the hard-disk was previously the only supported block
device, the block device read/write functions will now always fail,
returning -1.
Diffstat (limited to 'include/kernel')
| -rw-r--r-- | include/kernel/fs.h | 15 | ||||
| -rw-r--r-- | include/kernel/hd.h | 6 |
2 files changed, 16 insertions, 5 deletions
diff --git a/include/kernel/fs.h b/include/kernel/fs.h index a752ddf..4ec4de1 100644 --- a/include/kernel/fs.h +++ b/include/kernel/fs.h @@ -50,13 +50,24 @@ struct m_inode { uint16_t i_zone[9]; } __attribute__((packed)); +struct buffer { + void *b_data; + uint16_t b_device; + uint16_t b_block; + struct buffer *b_next; + struct buffer *b_prev; +} __attribute__((packed)); + extern struct super_block sblocks[NRSUPER]; -size_t block_read(void*, size_t , size_t); -size_t block_write(void*, size_t , size_t); +int block_read(void*, size_t); +int block_write(void*, size_t); void mount_root(void); void fs_init(void); +/* various init functions called by fs_init() */ +void buffer_init(void); + #endif diff --git a/include/kernel/hd.h b/include/kernel/hd.h index 7244c92..d4cf2e4 100644 --- a/include/kernel/hd.h +++ b/include/kernel/hd.h @@ -3,9 +3,9 @@ #include <sys/types.h> -void hd_init(void); +int hd_init(void); -size_t hd_read_block(void*, size_t , size_t); -size_t hd_write_block(void*, size_t , size_t); +int hd_read_block(void*, size_t); +int hd_write_block(void*, size_t); #endif |
