Adding FAT in the mbr, moving test and 'work' in the loader

This commit is contained in:
Adrien Bourmault 2018-12-20 18:24:09 +01:00
parent e1302cdbac
commit 7ac48c1893
3 changed files with 0 additions and 189 deletions

View File

@ -9,80 +9,3 @@
;=----------------------------------------------------------------------------=;
;-----------------------------------------------------------------------;
; Checks if the CPU is compatible with 64-bits operating systems ;
; If the 21th bit of the eax register is set, then CPUID is supported ;
; We then test CPUID's result to see if long mode is supported ;
;-----------------------------------------------------------------------;
[BITS 16]
Is64bits:
pushfd ; recovering the flags in eax
pop eax
mov ecx, eax
xor eax, 0x200000
push eax
popfd
pushfd
pop eax
xor eax, ecx
shr eax, 21
and eax, 1 ; magical spell of murta
push ecx
popfd
test eax, eax
jz .NonCompat ; if (CPUID non supporté) goto NonCompat
mov eax, 0x80000000
cpuid
cmp eax, 0x80000001
jb .NonCompat ; if (eax <= 0x80000001) goto NonCompat
mov eax, 0x80000001
cpuid
test edx, 1 << 29
jz .NonCompat ; if (edx != 1 << 29) goto NonCompat
ret ; back to mbr.s
.NonCompat:
stc
ret
;-------------------------------------------------------------------;
; loading second stage loader (loader.s) ;
;-------------------------------------------------------------------;
LoadSec:
;; prepare data for reading the disk
xor ax, ax
mov dl, [Bootdrv]
int 0x13
mov ax, SECOND_STAGE
mov es, ax
xor bx, bx
mov ah, 2 ; ah = 2 = function read sectors from disk
mov al, 2 ; al = number of sectors to read (1 - 128)
xor ch, ch ; ch = track/cylinder number
mov cl, 2 ; sector number
xor dh, dh ; dh = head number
mov dl, [Bootdrv]
int 0x13
jc .read_error
ret
.read_error:
popa
stc
ret

View File

@ -1,28 +0,0 @@
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Authors: spectral` //
// NeoX //
// //
// Desc: Kernel entry point //
//----------------------------------------------------------------------------//
extern void scrollup(unsigned int);
extern void print(char *);
extern kY;
extern kattr;
void _start(void)
{
kY = 18;
kattr = 0x5E;
print("un message\n");
kattr = 0x4E;
print("un autre message\n");
scrollup(2);
while (1);
}

View File

@ -1,84 +0,0 @@
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Authors: spectral` //
// NeoX //
// //
// Desc: Kernel screen func //
//----------------------------------------------------------------------------//
#include "types.h"
#define RAMSCREEN 0xB8000 /* debut de la memoire video */
#define SIZESCREEN 0xFA0 /* 4000, nombres d'octets d'une page texte */
#define SCREENLIM 0xB8FA0
char kX = 0; /* position courante du curseur a l'ecran */
char kY = 17;
char kattr = 0x0E; /* attributs video des caracteres a afficher */
/*
* 'scrollup' scrolle l'ecran (la console mappee en ram) vers le haut
* de n lignes (de 0 a 25).
*/
void scrollup(unsigned int n)
{
unsigned char *video, *tmp;
for (video = (unsigned char *) RAMSCREEN;
video < (unsigned char *) SCREENLIM; video += 2) {
tmp = (unsigned char *) (video + n * 160);
if (tmp < (unsigned char *) SCREENLIM) {
*video = *tmp;
*(video + 1) = *(tmp + 1);
} else {
*video = 0;
*(video + 1) = 0x07;
}
}
kY -= n;
if (kY < 0)
kY = 0;
}
void putcar(uchar c)
{
unsigned char *video;
int i;
if (c == 10) { /* CR-NL */
kX = 0;
kY++;
} else if (c == 9) { /* TAB */
kX = kX + 8 - (kX % 8);
} else if (c == 13) { /* CR */
kX = 0;
} else { /* autres caracteres */
video = (unsigned char *) (RAMSCREEN + 2 * kX + 160 * kY);
*video = c;
*(video + 1) = kattr;
kX++;
if (kX > 79) {
kX = 0;
kY++;
}
}
if (kY > 24)
scrollup(kY - 24);
}
/*
* 'print' affiche a l'ecran, a la position courante du curseur, une chaine
* de caracteres terminee par \0.
*/
void print(char *string)
{
while (*string != 0) { /* tant que le caractere est different de 0x0 */
putcar(*string);
string++;
}
}