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