forked from Bananymous/banan-os
Kernel: Add lock to Disk reads before I forget
This commit is contained in:
parent
ee5d02aa70
commit
7d84f290a1
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <BAN/Errors.h>
|
#include <BAN/Errors.h>
|
||||||
|
#include <kernel/SpinLock.h>
|
||||||
#include <kernel/Storage/StorageController.h>
|
#include <kernel/Storage/StorageController.h>
|
||||||
|
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
|
@ -33,6 +34,7 @@ namespace Kernel
|
||||||
char model[41];
|
char model[41];
|
||||||
|
|
||||||
ATABus* bus;
|
ATABus* bus;
|
||||||
|
SpinLock m_lock;
|
||||||
|
|
||||||
friend class ATAController;
|
friend class ATAController;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#include <kernel/IO.h>
|
#include <kernel/IO.h>
|
||||||
|
#include <kernel/LockGuard.h>
|
||||||
#include <kernel/Storage/ATAController.h>
|
#include <kernel/Storage/ATAController.h>
|
||||||
|
|
||||||
#include <kernel/kprint.h>
|
|
||||||
|
|
||||||
#define ATA_PRIMARY 0
|
#define ATA_PRIMARY 0
|
||||||
#define ATA_SECONDARY 1
|
#define ATA_SECONDARY 1
|
||||||
|
|
||||||
|
@ -189,6 +188,8 @@ namespace Kernel
|
||||||
if (lba + sector_count > lba_count)
|
if (lba + sector_count > lba_count)
|
||||||
return BAN::Error::from_string("Attempted to read outside of the device boundaries");
|
return BAN::Error::from_string("Attempted to read outside of the device boundaries");
|
||||||
|
|
||||||
|
LockGuard _(m_lock);
|
||||||
|
|
||||||
if (lba < (1 << 28))
|
if (lba < (1 << 28))
|
||||||
{
|
{
|
||||||
// LBA28
|
// LBA28
|
||||||
|
|
|
@ -106,9 +106,6 @@ extern "C" void kernel_main()
|
||||||
MUST(scheduler.add_thread(BAN::Function<void()>(
|
MUST(scheduler.add_thread(BAN::Function<void()>(
|
||||||
[terminal_driver]
|
[terminal_driver]
|
||||||
{
|
{
|
||||||
//PCI::get().initialize_controllers();
|
|
||||||
|
|
||||||
//StorageDeviceManager::initialize();
|
|
||||||
if (auto error = VirtualFileSystem::initialize(); error.is_error())
|
if (auto error = VirtualFileSystem::initialize(); error.is_error())
|
||||||
{
|
{
|
||||||
derrorln("{}", error.error());
|
derrorln("{}", error.error());
|
||||||
|
|
Loading…
Reference in New Issue