Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::drivers::disk::Disk Class Reference

Generic Disk, handles the reading and writing of data to the hard drive. More...

#include <disk.h>

Inheritance diagram for MaxOS::drivers::disk::Disk:
MaxOS::drivers::Driver MaxOS::drivers::disk::AdvancedTechnologyAttachment

Public Member Functions

void read (uint32_t sector, common::buffer_t *data_buffer)
 read data from the disk into a buffer (max capacity 512 bytes)
 
virtual void read (uint32_t sector, common::buffer_t *data_buffer, size_t amount)
 read data from the disk
 
void write (uint32_t sector, common::buffer_t *data)
 write data to the disk from a buffer (max capacity 512 bytes)
 
virtual void write (uint32_t sector, common::buffer_t *data, size_t count)
 write data to the disk
 
virtual void flush ()
 Flush the disk cache.
 
void activate () override
 Activate the disk driver.
 
string device_name () override
 Get the device name.
 
string vendor_name () override
 Get the vendor name.
 
- Public Member Functions inherited from MaxOS::drivers::Driver
virtual void deactivate ()
 Deactivate the driver.
 
virtual void initialise ()
 Initialise the driver.
 
virtual uint32_t reset ()
 Reset the driver.
 

Detailed Description

Generic Disk, handles the reading and writing of data to the hard drive.

Definition at line 24 of file disk.h.

Member Function Documentation

◆ activate()

void Disk::activate ( )
overridevirtual

Activate the disk driver.

Reimplemented from MaxOS::drivers::Driver.

Definition at line 78 of file disk.cpp.

78 {
80}
virtual void activate()
Activate the driver.
Definition driver.cpp:25

References MaxOS::drivers::Driver::activate().

◆ device_name()

string Disk::device_name ( )
overridevirtual

Get the device name.

Returns
The name of the device

Reimplemented from MaxOS::drivers::Driver.

Definition at line 87 of file disk.cpp.

87 {
88 return "Disk";
89}

◆ flush()

void Disk::flush ( )
virtual

Flush the disk cache.

This function is used to flush the disk cache to ensure that all data is written to the disk.

Reimplemented in MaxOS::drivers::disk::AdvancedTechnologyAttachment.

Definition at line 72 of file disk.cpp.

72 {
73}

◆ read() [1/2]

void Disk::read ( uint32_t  sector,
common::buffer_t data_buffer 
)

read data from the disk into a buffer (max capacity 512 bytes)

Parameters
sectorThe sector to read from
data_bufferThe buffer to read the data into

Definition at line 26 of file disk.cpp.

26 {
27
28 size_t amount = (data_buffer->capacity() > 512) ? 512 : data_buffer->capacity();
30
31}
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
void read(uint32_t sector, common::buffer_t *data_buffer)
read data from the disk into a buffer (max capacity 512 bytes)
Definition disk.cpp:26

References read().

Referenced by MaxOS::filesystem::format::Fat32Volume::Fat32Volume(), MaxOS::filesystem::partition::MSDOSPartition::mount_partitions(), MaxOS::filesystem::format::Fat32Volume::next_cluster(), MaxOS::filesystem::format::Fat32File::read(), read(), MaxOS::filesystem::format::ext2::Ext2Volume::read_block(), MaxOS::filesystem::format::Fat32Volume::set_next_cluster(), MaxOS::filesystem::format::Fat32Directory::update_entry_on_disk(), and MaxOS::filesystem::format::Fat32File::write().

◆ read() [2/2]

void Disk::read ( uint32_t  sector,
common::buffer_t data_buffer,
size_t  amount 
)
virtual

read data from the disk

Parameters
sectorThe sector to read from
data_bufferThe buffer to read the data into
amountThe amount of data to read

Reimplemented in MaxOS::drivers::disk::AdvancedTechnologyAttachment.

Definition at line 40 of file disk.cpp.

40 {
41
42}

◆ vendor_name()

string Disk::vendor_name ( )
overridevirtual

Get the vendor name.

Returns
The name of the vendor

Reimplemented from MaxOS::drivers::Driver.

Definition at line 96 of file disk.cpp.

96 {
97 return "Generic";
98}

◆ write() [1/2]

void Disk::write ( uint32_t  sector,
common::buffer_t data 
)

write data to the disk from a buffer (max capacity 512 bytes)

Parameters
sectorThe sector to write to
dataThe buffer to write the data from

Definition at line 50 of file disk.cpp.

50 {
51
52 size_t amount = (data->capacity() > 512) ? 512 : data->capacity();
53 write(sector, data, amount);
54
55}
void write(uint32_t sector, common::buffer_t *data)
write data to the disk from a buffer (max capacity 512 bytes)
Definition disk.cpp:50

References MaxOS::common::Buffer::capacity(), and write().

Referenced by MaxOS::filesystem::format::Fat32Volume::allocate_cluster(), MaxOS::filesystem::format::Fat32Volume::free_cluster(), MaxOS::filesystem::format::Fat32Volume::set_next_cluster(), MaxOS::filesystem::format::Fat32Directory::update_entry_on_disk(), MaxOS::filesystem::format::Fat32File::write(), write(), and MaxOS::filesystem::format::ext2::Ext2Volume::write_block().

◆ write() [2/2]

void Disk::write ( uint32_t  sector,
common::buffer_t data,
size_t  count 
)
virtual

write data to the disk

Parameters
sectorThe sector to write to
dataThe buffer to write the data into
countThe amount of data to write

Reimplemented in MaxOS::drivers::disk::AdvancedTechnologyAttachment.

Definition at line 64 of file disk.cpp.

64 {
65}

The documentation for this class was generated from the following files: