mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
Add a simple IDEDiskDevice class that implements DiskDevice from VFS.
This commit is contained in:
parent
8293a0ff36
commit
12e515735b
Notes:
sideshowbarker
2024-07-19 18:47:19 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/12e515735b9
6 changed files with 88 additions and 11 deletions
|
@ -1,8 +1,2 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "kassert.h"
|
||||||
#include "VGA.h"
|
|
||||||
|
|
||||||
#define CRASH() do { asm volatile("cli;hlt"); } while(0)
|
|
||||||
#define ASSERT(x) do { if (!(x)) { vga_set_attr(0x4f); kprintf("ASSERTION FAILED: " #x "\n%s:%u in %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); CRASH(); } } while(0)
|
|
||||||
#define RELEASE_ASSERT(x) do { if (!(x)) CRASH(); } while(0)
|
|
||||||
#define ASSERT_NOT_REACHED() ASSERT(false)
|
|
||||||
|
|
41
Kernel/IDEDiskDevice.cpp
Normal file
41
Kernel/IDEDiskDevice.cpp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#include "IDEDiskDevice.h"
|
||||||
|
#include "Disk.h"
|
||||||
|
|
||||||
|
RetainPtr<IDEDiskDevice> IDEDiskDevice::create()
|
||||||
|
{
|
||||||
|
return adopt(*new IDEDiskDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
IDEDiskDevice::IDEDiskDevice()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IDEDiskDevice::~IDEDiskDevice()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* IDEDiskDevice::className() const
|
||||||
|
{
|
||||||
|
return "IDEDiskDevice";
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned IDEDiskDevice::blockSize() const
|
||||||
|
{
|
||||||
|
return 512;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDEDiskDevice::readBlock(unsigned index, byte* out) const
|
||||||
|
{
|
||||||
|
Disk::readSectors(index, 1, out);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDEDiskDevice::writeBlock(unsigned index, const byte* data)
|
||||||
|
{
|
||||||
|
(void) index;
|
||||||
|
(void) data;
|
||||||
|
kprintf("[IDEDiskDevice] writeBlock not implemented()\n");
|
||||||
|
notImplemented();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
21
Kernel/IDEDiskDevice.h
Normal file
21
Kernel/IDEDiskDevice.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/RetainPtr.h>
|
||||||
|
#include <VirtualFileSystem/DiskDevice.h>
|
||||||
|
|
||||||
|
class IDEDiskDevice final : public DiskDevice {
|
||||||
|
public:
|
||||||
|
static RetainPtr<IDEDiskDevice> create();
|
||||||
|
virtual ~IDEDiskDevice();
|
||||||
|
|
||||||
|
virtual unsigned blockSize() const override;
|
||||||
|
virtual bool readBlock(unsigned index, byte*) const override;
|
||||||
|
virtual bool writeBlock(unsigned index, const byte*) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
IDEDiskDevice();
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual const char* className() const override;
|
||||||
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
OBJS = \
|
KERNEL_OBJS = \
|
||||||
_start.o \
|
_start.o \
|
||||||
init.o \
|
init.o \
|
||||||
VGA.o \
|
VGA.o \
|
||||||
|
@ -18,7 +18,14 @@ OBJS = \
|
||||||
panel.o \
|
panel.o \
|
||||||
Disk.o \
|
Disk.o \
|
||||||
fs.o \
|
fs.o \
|
||||||
Userspace.o
|
Userspace.o \
|
||||||
|
IDEDiskDevice.o
|
||||||
|
|
||||||
|
VFS_OBJS = \
|
||||||
|
../VirtualFileSystem/DiskDevice.o
|
||||||
|
|
||||||
|
OBJS = $(KERNEL_OBJS) $(VFS_OBJS)
|
||||||
|
|
||||||
NASM = nasm
|
NASM = nasm
|
||||||
KERNEL = kernel
|
KERNEL = kernel
|
||||||
BOOTLOADER = Boot/boot.bin
|
BOOTLOADER = Boot/boot.bin
|
||||||
|
@ -30,8 +37,11 @@ WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings
|
||||||
FLAVOR_FLAGS = -fomit-frame-pointer -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fmerge-all-constants -fno-unroll-loops -falign-functions=1 -falign-jumps=1 -falign-loops=1
|
FLAVOR_FLAGS = -fomit-frame-pointer -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fmerge-all-constants -fno-unroll-loops -falign-functions=1 -falign-jumps=1 -falign-loops=1
|
||||||
#FLAVOR_FLAGS = -fomit-frame-pointer -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections
|
#FLAVOR_FLAGS = -fomit-frame-pointer -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections
|
||||||
OPTIMIZATION_FLAGS = -Os -fno-asynchronous-unwind-tables
|
OPTIMIZATION_FLAGS = -Os -fno-asynchronous-unwind-tables
|
||||||
INCLUDE_FLAGS = -Iinclude/ -I.
|
INCLUDE_FLAGS = -I.. -I.
|
||||||
CXXFLAGS = $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(KERNEL_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS)
|
|
||||||
|
DEFINES = -DSERENITY_KERNEL -DSANITIZE_PTRS
|
||||||
|
|
||||||
|
CXXFLAGS = $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(KERNEL_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES)
|
||||||
#CXX = /usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-g++
|
#CXX = /usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-g++
|
||||||
#LD = /usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-ld
|
#LD = /usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-ld
|
||||||
CXX = g++
|
CXX = g++
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "CMOS.h"
|
#include "CMOS.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "Userspace.h"
|
#include "Userspace.h"
|
||||||
|
#include "IDEDiskDevice.h"
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Keyboard LED disco task ;^) */
|
/* Keyboard LED disco task ;^) */
|
||||||
|
@ -123,6 +124,8 @@ void init()
|
||||||
Disk::initialize();
|
Disk::initialize();
|
||||||
FileSystem::initialize();
|
FileSystem::initialize();
|
||||||
|
|
||||||
|
auto hd0 = IDEDiskDevice::create();
|
||||||
|
|
||||||
// new Task(motd_main, "motd", IPC::Handle::MotdTask, Task::Ring0);
|
// new Task(motd_main, "motd", IPC::Handle::MotdTask, Task::Ring0);
|
||||||
new Task(user_main, "user", IPC::Handle::UserTask, Task::Ring3);
|
new Task(user_main, "user", IPC::Handle::UserTask, Task::Ring3);
|
||||||
|
|
||||||
|
|
8
Kernel/kassert.h
Normal file
8
Kernel/kassert.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "VGA.h"
|
||||||
|
|
||||||
|
#define CRASH() do { asm volatile("cli;hlt"); } while(0)
|
||||||
|
#define ASSERT(x) do { if (!(x)) { vga_set_attr(0x4f); kprintf("ASSERTION FAILED: " #x "\n%s:%u in %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); CRASH(); } } while(0)
|
||||||
|
#define RELEASE_ASSERT(x) do { if (!(x)) CRASH(); } while(0)
|
||||||
|
#define ASSERT_NOT_REACHED() ASSERT(false)
|
Loading…
Reference in a new issue