mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Some tests on ATA driver
This commit is contained in:
parent
f3b7b85da8
commit
4ff65f57d0
19
Makefile
19
Makefile
@ -108,7 +108,7 @@ KernSources = kernel/ke/cpuid.c kernel/mm/paging.c \
|
||||
kernel/ke/rtc.c kernel/io/keyb.c \
|
||||
kernel/io/spkr.c kernel/po/shtdwn.c \
|
||||
kernel/sh/shell.c kernel/sh/shcmds.c \
|
||||
kernel/sh/musage.c
|
||||
kernel/sh/musage.c kernel/io/ata.c
|
||||
|
||||
KernObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(KernSources))
|
||||
KernDep=$(patsubst %.c,$(KOBJDIR)/%.d,$(KernSources))
|
||||
@ -168,6 +168,15 @@ $(KOBJDIR)/kernel/ke/idt.o: $(KALEIDDIR)/kernel/ke/idt.c \
|
||||
@rm -f $@.1 $@.2
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
|
||||
$(KOBJDIR)/kernel/ke/cpuid.o: $(KALEIDDIR)/kernel/ke/cpuid.c \
|
||||
$(KALEIDDIR)/kernel/ke/cpuf.asm | $(KOBJDIR)
|
||||
@mkdir -p $(shell dirname $@)
|
||||
@$(ASM) $(ASMFLAGS) $(KALEIDDIR)/kernel/ke/cpuf.asm -o $@.1
|
||||
@$(KCC_MATHS) $< -o $@.2
|
||||
@$(LD) $(LDFLAGS) -r $@.1 $@.2 -o $@
|
||||
@rm -f $@.1 $@.2
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
|
||||
$(KOBJDIR)/kernel/mm/paging.o: $(KALEIDDIR)/kernel/mm/paging.c \
|
||||
$(KALEIDDIR)/kernel/mm/paging.asm | $(KOBJDIR)
|
||||
@mkdir -p $(shell dirname $@)
|
||||
@ -186,11 +195,11 @@ $(KOBJDIR)/kernel/mm/gdt.o: $(KALEIDDIR)/kernel/mm/gdt.c \
|
||||
@rm -f $@.1 $@.2
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
|
||||
$(KOBJDIR)/kernel/ke/cpuid.o: $(KALEIDDIR)/kernel/ke/cpuid.c \
|
||||
$(KALEIDDIR)/kernel/ke/cpuf.asm | $(KOBJDIR)
|
||||
$(KOBJDIR)/kernel/io/ata.o: $(KALEIDDIR)/kernel/io/ata.c \
|
||||
$(KALEIDDIR)/kernel/io/ata.asm | $(KOBJDIR)
|
||||
@mkdir -p $(shell dirname $@)
|
||||
@$(ASM) $(ASMFLAGS) $(KALEIDDIR)/kernel/ke/cpuf.asm -o $@.1
|
||||
@$(KCC_MATHS) $< -o $@.2
|
||||
@$(ASM) $(ASMFLAGS) $(KALEIDDIR)/kernel/io/ata.asm -o $@.1
|
||||
@$(KCC) $< -o $@.2
|
||||
@$(LD) $(LDFLAGS) -r $@.1 $@.2 -o $@
|
||||
@rm -f $@.1 $@.2
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
|
@ -158,6 +158,12 @@ extern void MmLoadGdt(GdtPtr_t *gdtPtr, ushort tssOffset);
|
||||
//
|
||||
extern void MmStoreGdt(void);
|
||||
|
||||
void MmInitPaging(void);
|
||||
|
||||
void MmReloadPaging(void);
|
||||
|
||||
void MmActivatePageHandler(void);
|
||||
|
||||
//
|
||||
// Returns the address of the stack guard pages
|
||||
//
|
||||
|
@ -24,9 +24,6 @@
|
||||
|
||||
#include "init.h"
|
||||
|
||||
void MmInitPaging(void);
|
||||
void MmActivatePageHandler(void);
|
||||
|
||||
//
|
||||
// Entry point of the Kaleid kernel
|
||||
//
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <mm/mm.h>
|
||||
#include <io/vga.h>
|
||||
#include <ke/cpuid.h>
|
||||
#include <io/ata.h>
|
||||
|
||||
// info.c
|
||||
extern void BtDoSanityChecks(uint mbMagic);
|
||||
|
@ -23,6 +23,9 @@
|
||||
; along with OS/K. If not, see <https://www.gnu.org/licenses/>. ;
|
||||
;=----------------------------------------------------------------------------=;
|
||||
|
||||
global IoReadATA
|
||||
extern KernLog
|
||||
|
||||
[BITS 64]
|
||||
|
||||
;; BPB
|
||||
@ -47,18 +50,14 @@
|
||||
%define fatTypeLabel bp+0x36 ; File system type
|
||||
|
||||
;; GLOBAL DATA
|
||||
|
||||
Bootdrv db 0
|
||||
ended db "[End of Sector]", 0x0A, 0x0A, 0x0D, 0x0
|
||||
buffer: times 513 db "_", 0
|
||||
|
||||
;; TEXT
|
||||
|
||||
ata_read:
|
||||
IoReadATA:
|
||||
;-----------------------------------------------------------------------;
|
||||
; x64/LM ATA Reading function ;
|
||||
; bl : number of sectors to read XXX ;
|
||||
; bh : the first sector to read ;
|
||||
; rsi : number of sectors to read XXX ;
|
||||
; rdx : the first sector to read ;
|
||||
;-----------------------------------------------------------------------;
|
||||
|
||||
; Technical infos about the ports (Intel Doc):
|
||||
@ -99,11 +98,10 @@ ata_read:
|
||||
; 32h write long with retry
|
||||
; 33h write long without retry
|
||||
;
|
||||
push rax
|
||||
push rbx
|
||||
push rcx
|
||||
push rdx
|
||||
push rdi
|
||||
mov bh, dl
|
||||
mov dx, si
|
||||
mov bl, dl
|
||||
mov dx, 0x1f6 ; Drive and head port
|
||||
mov al, 0x0a0 ; Drive 0, head 0
|
||||
out dx,al
|
||||
@ -135,18 +133,7 @@ still_going:
|
||||
;is ready.
|
||||
|
||||
mov cx, 512/2 ; One sector /2 because it copies words
|
||||
mov rdi, QWORD buffer
|
||||
mov dx, 0x1f0 ; Data port - data comes in and out of here.
|
||||
rep insw
|
||||
pop rdi
|
||||
mov bl, 0x0F
|
||||
mov rdi, QWORD buffer
|
||||
call KernLog
|
||||
mov bl, 0x0A
|
||||
mov rdi, ended
|
||||
call KernLog
|
||||
pop rdx
|
||||
pop rcx
|
||||
pop rbx
|
||||
pop rax
|
||||
ret
|
||||
|
@ -24,6 +24,17 @@
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
|
||||
int ShAtoi(char* str)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
for (int i = 0; str[i] != 0; ++i)
|
||||
res = res * 10 + str[i] - '0';
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
error_t CmdArgs(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
int i;
|
||||
@ -114,6 +125,31 @@ error_t CmdDie(int argc, char **argv, char *cmdline)
|
||||
return EOK;
|
||||
}
|
||||
|
||||
error_t CmdDumpATASect(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
char sector[513] = {0};
|
||||
int sectNumber = ShAtoi(argv[1]);
|
||||
|
||||
if (!sectNumber) {
|
||||
KernLog("Bad argument\n\n");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
KernLog("Sector number: %d\n", sectNumber);
|
||||
|
||||
IoReadATA(sector, 1, sectNumber);
|
||||
|
||||
for (int i = 0; i < 513; i++) {
|
||||
if (isprint(sector[i]))
|
||||
KernLog("%c", sector[i]);
|
||||
else
|
||||
KernLog(" ");
|
||||
}
|
||||
|
||||
KernLog("\n\n");
|
||||
return EOK;
|
||||
}
|
||||
|
||||
error_t CmdHelp(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
uint i, count = 0;
|
||||
@ -242,10 +278,11 @@ Command_t cmdtable[] =
|
||||
{ "cpuid", CmdCpuid, "Request a cpuid info." },
|
||||
{ "date", CmdDate, "Print date" },
|
||||
{ "die", CmdDie, "Die painfully" },
|
||||
{ "dmpsec", CmdDumpATASect, "Dump an ATA sector on screen" },
|
||||
{ "help", CmdHelp, "Show this message" },
|
||||
{ "mmap", CmdMemMap, "Show memory map" },
|
||||
{ "musage", CmdMemUsage, "Show memory statistics" },
|
||||
{ "pfault", CmdPF, "Provoke a PF. Usage : pfault <address>" },
|
||||
{ "pfault", CmdPF, "Provoke a PF. Usage: pfault <address>"},
|
||||
{ "pstest", CmdPsTest, "Scheduler test routine" },
|
||||
{ "exit", CmdQuit, "Initiate shutdown" },
|
||||
{ "quit", CmdQuit, "Alias for 'exit'" },
|
||||
@ -253,9 +290,8 @@ Command_t cmdtable[] =
|
||||
{ "shell", CmdShell, "Start a new shell (nested)", },
|
||||
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
||||
{ "stkun", CmdStackUnderflow, "Provoke a stack underflow" },
|
||||
{ "march", CmdStarWars, "Play the Imperial March"},
|
||||
{ "march", CmdStarWars, "Play the Imperial March" },
|
||||
{ "time", CmdTime, "Print time" },
|
||||
{ "test", CmdTime, "Undocumented (various tests)" },
|
||||
{ "ver", CmdVersion, "Version and legal infos" },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
@ -35,13 +35,10 @@
|
||||
#include <io/vga.h>
|
||||
#include <po/shtdwn.h>
|
||||
#include <ke/cpuid.h>
|
||||
#include <io/ata.h>
|
||||
|
||||
void IoScrollDown(void);
|
||||
void IoScrollUp(void);
|
||||
void KeStartShell(void);
|
||||
void pstest(void);
|
||||
void MmInitPaging(void);
|
||||
void MmReloadPaging(void);
|
||||
|
||||
extern int shcol;
|
||||
extern int shargc;
|
||||
|
@ -45,4 +45,3 @@ _ATOI_IMPL(atoul, ulong, strtoul)
|
||||
#else
|
||||
#error "What am I supposed to declare?"
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user