mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Merge branch 'disk'
This commit is contained in:
commit
494e85e6dc
14
Makefile
14
Makefile
@ -318,21 +318,21 @@ test: all installonimage
|
||||
run: test
|
||||
|
||||
testnokvm: all installonimage
|
||||
@qemu-system-x86_64 -vga std -cpu $(cpu) -soundhw pcspk -s \
|
||||
@qemu-system-x86_64 -vga std -cpu $(cpu) -machine type=q35 -soundhw pcspk -s \
|
||||
-rtc base=localtime -m $(ram) -hda $(installdisk) \
|
||||
-d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
|
||||
|
||||
testnosnd: all installonimage
|
||||
@qemu-system-x86_64 -vga std -enable-kvm -cpu host -s \
|
||||
@qemu-system-x86_64 -vga std -enable-kvm -machine type=q35 -cpu host -s \
|
||||
-rtc base=localtime -m $(ram) -hda $(installdisk) \
|
||||
-d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
|
||||
|
||||
test32: all installonimage
|
||||
@qemu-system-i386 -m $(ram) -hda $(installdisk) -d \
|
||||
@qemu-system-i386 -m $(ram) -hda $(installdisk) -machine type=q35 -d \
|
||||
cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
|
||||
|
||||
gdb: all installonimage
|
||||
@setsid qemu-system-x86_64 -m $(ram) -enable-kvm -rtc base=localtime \
|
||||
@setsid qemu-system-x86_64 -m $(ram) -enable-kvm -machine type=q35 -rtc base=localtime \
|
||||
-hda $(installdisk) -no-reboot -no-shutdown -d \
|
||||
cpu_reset,guest_errors,pcall,int -s -S 2> $(BUILDDIR)/qemu.log &
|
||||
@gdb \
|
||||
@ -342,13 +342,13 @@ gdb: all installonimage
|
||||
-ex "break BtStartKern" \
|
||||
|
||||
ddd: all installonimage
|
||||
@setsid qemu-system-x86_64 -m $(ram) -enable-kvm -rtc base=localtime \
|
||||
@setsid qemu-system-x86_64 -m $(ram) -enable-kvm -machine type=q35 -rtc base=localtime \
|
||||
-hda $(installdisk) -no-reboot -no-shutdown -d \
|
||||
cpu_reset,guest_errors,pcall,int -s -S 2> $(BUILDDIR)/qemu.log &
|
||||
@ddd -n
|
||||
|
||||
gdbnokvm: all installonimage
|
||||
@setsid qemu-system-x86_64 -m $(ram) -rtc base=localtime \
|
||||
@setsid qemu-system-x86_64 -m $(ram) -machine type=q35 -rtc base=localtime \
|
||||
-hda $(installdisk) -no-reboot -no-shutdown -d \
|
||||
cpu_reset,guest_errors,pcall,int -s -S 2> $(BUILDDIR)/qemu.log &
|
||||
@gdb \
|
||||
@ -358,7 +358,7 @@ gdbnokvm: all installonimage
|
||||
-ex "break BtStartKern" \
|
||||
|
||||
dddnokvm: all installonimage
|
||||
@setsid qemu-system-x86_64 -m $(ram) -rtc base=localtime \
|
||||
@setsid qemu-system-x86_64 -m $(ram) -machine type=q35 -rtc base=localtime \
|
||||
-hda $(installdisk) -no-reboot -no-shutdown -d \
|
||||
cpu_reset,guest_errors,pcall,int -s -S 2> $(BUILDDIR)/qemu.log &
|
||||
@ddd -n
|
||||
|
@ -33,6 +33,96 @@
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#define MASS_STORAGE_CLASS 0x1
|
||||
#define SERIAL_ATA_SUBCLASS 0x6
|
||||
|
||||
enum
|
||||
{
|
||||
REG_H2D = 0x27, // Register FIS - host to device
|
||||
REG_D2H = 0x34, // Register FIS - device to host
|
||||
DMA_ACT = 0x39, // DMA activate FIS - device to host
|
||||
DMA_SETUP = 0x41, // DMA setup FIS - bidirectional
|
||||
DATA = 0x46, // Data FIS - bidirectional
|
||||
BIST = 0x58, // BIST activate FIS - bidirectional
|
||||
PIO_SETUP = 0x5F, // PIO setup FIS - device to host
|
||||
DEV_BITS = 0xA1 // Set device bits FIS - device to host
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
IDENTIFY = 0xEC // CMD IDENTIFY
|
||||
};
|
||||
|
||||
struct HostToDeviceFIS
|
||||
{
|
||||
// DWORD 0
|
||||
uchar type; // REG_H2D
|
||||
|
||||
uchar pmport:4; // Port multiplier
|
||||
uchar reserved0:3; // Reserved
|
||||
uchar c:1; // 1: Command, 0: Control
|
||||
|
||||
uchar command; // Command register
|
||||
uchar featurel; // Feature register, 7:0
|
||||
|
||||
// DWORD 1
|
||||
uchar lba0; // LBA low register, 7:0
|
||||
uchar lba1; // LBA mid register, 15:8
|
||||
uchar lba2; // LBA high register, 23:16
|
||||
uchar device; // Device register
|
||||
|
||||
// DWORD 2
|
||||
uchar lba3; // LBA register, 31:24
|
||||
uchar lba4; // LBA register, 39:32
|
||||
uchar lba5; // LBA register, 47:40
|
||||
uchar featureh; // Feature register, 15:8
|
||||
|
||||
// DWORD 3
|
||||
uchar countl; // Count register, 7:0
|
||||
uchar counth; // Count register, 15:8
|
||||
uchar icc; // Isochronous command completion
|
||||
uchar control; // Control register
|
||||
|
||||
// DWORD 4
|
||||
uchar reserved1[4]; // Reserved
|
||||
};
|
||||
|
||||
struct DMASetupFIS
|
||||
{
|
||||
// DWORD 0
|
||||
uchar type; // DMA_SETUP
|
||||
|
||||
uchar pmport:4; // Port multiplier
|
||||
uchar reserved0:1; // Reserved
|
||||
uchar d:1; // Data transfer direction, 1 - device to host
|
||||
uchar i:1; // Interrupt bit
|
||||
uchar a:1; // Auto-activate. Specifies if DMA Activate FIS
|
||||
// is needed
|
||||
|
||||
uchar reserved1[2]; // Reserved
|
||||
|
||||
//DWORD 1&2
|
||||
ulong DMAbufferID; // DMA Buffer Identifier.
|
||||
// Used to Identify DMA buffer in host memory.
|
||||
// SATA Spec says host specific and not in Spec.
|
||||
// Trying AHCI spec might work.
|
||||
|
||||
//DWORD 3
|
||||
uint reserved2; // More reserved
|
||||
|
||||
//DWORD 4
|
||||
uint DMAbufOffset; // Byte offset into buffer. First 2 bits must be 0
|
||||
|
||||
//DWORD 5
|
||||
uint TransferCount; // Number of bytes to transfer. Bit 0 must be 0
|
||||
|
||||
//DWORD 6
|
||||
uint reserved3; // Reserved
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
void IoDetectATA(void);
|
||||
void IoReadATA(void *sectorBuffer, char n, char first);
|
||||
void IoDumpSector(void);
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <drivers/ata.h>
|
||||
#include <io/vga.h>
|
||||
#include <io/pci.h>
|
||||
|
||||
void IoDumpFirstSector(void)
|
||||
{
|
||||
@ -41,3 +42,25 @@ void IoDumpFirstSector(void)
|
||||
|
||||
KernLog("\n\n");
|
||||
}
|
||||
|
||||
void IoDetectATA(void)
|
||||
{
|
||||
PciDev_t *ataDevice = IoPciGetDeviceByClass(MASS_STORAGE_CLASS,
|
||||
SERIAL_ATA_SUBCLASS);
|
||||
|
||||
if(!ataDevice) {
|
||||
return;
|
||||
}
|
||||
|
||||
DebugLog("AHCI controller found at PCI config addr = %p\n",
|
||||
ataDevice->configAddr);
|
||||
|
||||
struct HostToDeviceFIS fis;
|
||||
memset(&fis, 0, sizeof(struct HostToDeviceFIS));
|
||||
fis.type = REG_H2D;
|
||||
fis.command = IDENTIFY;
|
||||
fis.device = 0; // Master
|
||||
fis.c = 1; // This is a command
|
||||
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <io/pci.h>
|
||||
#include <po/shtdwn.h>
|
||||
#include <init/boot.h>
|
||||
|
||||
#include <drivers/ata.h>
|
||||
//
|
||||
// Entry point of the Kaleid kernel
|
||||
//
|
||||
@ -88,6 +88,9 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
||||
// PCI express
|
||||
IoInitPCI();
|
||||
|
||||
// Drivers
|
||||
IoDetectATA();
|
||||
|
||||
// Scheduler
|
||||
PsInitSched();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user