1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

Work on HD

This commit is contained in:
Adrien Bourmault 2019-05-23 23:21:58 +02:00
parent 4ff65f57d0
commit d0e7d197c1
3 changed files with 103 additions and 6 deletions

41
include/io/ata.h Normal file
View File

@ -0,0 +1,41 @@
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Desc: Basic Read Only ATA Long mode Driver //
// //
// //
// Copyright © 2018-2019 The OS/K Team //
// //
// This file is part of OS/K. //
// //
// OS/K is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// any later version. //
// //
// OS/K is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#ifndef _KERNEL_H
#include <kernel.h>
#endif
#ifndef _IO_ATA_H
#define _IO_ATA_H
#include <ke/idt.h>
//----------------------------------------------------------------------------//
void IoReadATA(void *sectorBuffer, char n, char first);
void IoDumpSector(void);
//----------------------------------------------------------------------------//
#endif

43
kaleid/kernel/io/ata.c Normal file
View File

@ -0,0 +1,43 @@
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Desc: Basic Read Only ATA Long mode Driver //
// //
// //
// Copyright © 2018-2019 The OS/K Team //
// //
// This file is part of OS/K. //
// //
// OS/K is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// any later version. //
// //
// OS/K is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <io/ata.h>
#include <io/vga.h>
void IoDumpFirstSector(void)
{
char sector[513] = {0};
KernLog("Sector addr : %p\n", &sector[0]);
IoReadATA(sector, 1, 1);
for (int i = 0; i < 513; i++) {
if (isascii(sector[i]))
KernLog("%c", sector[i]);
else
KernLog(" ");
}
KernLog("\n\n");
}

View File

@ -127,8 +127,10 @@ error_t CmdDie(int argc, char **argv, char *cmdline)
error_t CmdDumpATASect(int argc, char **argv, char *cmdline) error_t CmdDumpATASect(int argc, char **argv, char *cmdline)
{ {
char sector[513] = {0}; char sector[600] = {0};
int sectNumber = ShAtoi(argv[1]); int sectNumber = ShAtoi(argv[1]);
int x = 0;
size_t ret;
if (!sectNumber) { if (!sectNumber) {
KernLog("Bad argument\n\n"); KernLog("Bad argument\n\n");
@ -139,11 +141,22 @@ error_t CmdDumpATASect(int argc, char **argv, char *cmdline)
IoReadATA(sector, 1, sectNumber); IoReadATA(sector, 1, sectNumber);
for (int i = 0; i < 513; i++) { while(x < 513) {
if (isprint(sector[i])) for (int i = 0; i < 13; i++) {
KernLog("%c", sector[i]); KernLog("%02x ", (uchar)sector[i+x]);
else }
KernLog(" "); KernLog(" ");
for (int i = 0; i < 13; i++) {
if (isprint(sector[i+x]))
KernLog("%C%c%C",
VGA_COLOR_LIGHT_BLUE,
sector[i+x],
shcol);
else
KernLog("%c", 0);
}
KernLog("\n");
x += 20;
} }
KernLog("\n\n"); KernLog("\n\n");