Today I added ide driver. It was relatively easy, because I used pre-existing driver that I created in last operating system project. Upon adding the driver, I noticed some major issues on my system. First, I actually fixed the block size to the Driver, not the Block Device. I realized that not every devices that use one driver have same block size, such as ide cd driver having to deal with sector size that's different to each CD brand. Second, I found out that there's no way of getting the total block count and block size in current system. We need to make a field in the block_device structure that describes the total block count and block size. How are we going to get that information? Maybe by using io_read io_write function? or create completely new function that dedicates to find the total block count and block size? idk..
Upon researching about linux's block device driver, I figured out that there's get_geo() function that gets the geometry from the device driver. I think I should also implement this..?? idk
Somehow more I look at linux kernel's code, more I get that feeling of dejection.. I feel like my kernel's just worthless compare to linux kernel. Well, but I don't do this to earn some fame or some kind of money.. so who cares! I just have to enjoy the process of learning something..!
Anyways, forget all the gibberish I said. I just decided to add get_geometry() function to the block_device_driver. Now when device is registered, the register_device() function tries to get the geometry of the device. Here's some code :
/// @brief Registeres device to driver (kernel)
/// @param driver Target driver
/// @param device Device to be registered
/// @return Return the id of the device
max_t blockdev::register_device(blockdev::block_device_driver *driver , blockdev::block_device *device) {
debug::push_function("blockdev::reg_dev");
BlockDeviceDriverContainer *driver_container = BlockDeviceDriverContainer::get_self();
device->id = driver->device_container->register_object(device);
if(device->id == INVALID) return INVALID;
if(driver->get_geometry(device , device->geometry) == false) return INVALID;
device->device_driver = driver;
return device->id;
}
But while I was implementing ide drivers, I found out that there's something wrong with the interrupt system. The gist here is that because the ISR is not completely implemented yet, I got to implement ISR to make interrupt work. I think I disregarded some details and just thought it would work. How stupid.. lol