[boot] Move read to the C so we can pass it arguments easily.
This commit is contained in:
parent
76c8c1652f
commit
ed99d52ada
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ bootloader/stage2.bin
|
||||
initrd/kernel
|
||||
initrd/stage2
|
||||
.gdb_history
|
||||
testdisk
|
||||
|
2
Makefile
2
Makefile
@ -99,7 +99,7 @@ bootloader/stage2.bin: bootloader/stage2/main.o bootloader/stage2/start.o bootlo
|
||||
@${ECHO} "\r\033[32;1m ld $<\033[0m"
|
||||
|
||||
testdisk: bootloader/stage1.bin bootloader/stage2.bin
|
||||
cat bootloader/stage1.bin herp bootloader/stage1.bin > testdisk
|
||||
cat bootloader/stage1.bin README.md > testdisk
|
||||
|
||||
###############
|
||||
# clean #
|
||||
|
@ -13,13 +13,32 @@ void kprint(short s)
|
||||
"call _print" : : "l" ((short)s));
|
||||
}
|
||||
|
||||
void read(unsigned char count, unsigned char sector, short segment, short offset)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"movw %0, %%es\n"
|
||||
"movw %1, %%bx\n"
|
||||
"movb %2, %%al\n"
|
||||
"movb $0, %%ch\n"
|
||||
"movb %3, %%cl\n"
|
||||
"movb $0, %%dh\n"
|
||||
"movb $0x80, %%dl\n"
|
||||
"movb $0x02, %%ah\n"
|
||||
"int $0x13" : :
|
||||
"l" (segment),
|
||||
"l" (offset),
|
||||
"m" (count),
|
||||
"m" (sector));
|
||||
}
|
||||
|
||||
/*
|
||||
* Main entry point
|
||||
*/
|
||||
int main() {
|
||||
kprint((short)(int)"Welcome to C!\r\n");
|
||||
|
||||
__asm__("calll _readn");
|
||||
//__asm__("calll _readn");
|
||||
read(1,3,0,0x7e00);
|
||||
|
||||
kprint((short)(int)"Contents of 0x7e00:\r\n");
|
||||
kprint(0x7e00);
|
||||
|
@ -18,8 +18,6 @@
|
||||
.text
|
||||
|
||||
.global _start
|
||||
.global _print
|
||||
.global _readn
|
||||
_start:
|
||||
movw $0x00,%ax # Initialize segments...
|
||||
movw %ax,%ds # ... data
|
||||
@ -38,19 +36,7 @@ _start:
|
||||
calll _print # ...
|
||||
hlt
|
||||
|
||||
_readn:
|
||||
movw $0x0000, %ax # We are segment 0...
|
||||
movw %ax, %es
|
||||
movw $0x7e00, %bx # Address to put output
|
||||
movb $0x01, %al # Count
|
||||
movb $0x00, %ch # Track
|
||||
movb $0x02, %cl # Sector
|
||||
movb $0x00, %dh # Head
|
||||
movb $0x80, %dl # Disk
|
||||
movb $0x02, %ah # Command number
|
||||
int $0x13
|
||||
retl
|
||||
|
||||
.global _print
|
||||
_print:
|
||||
movb $0x0E,%ah # set registers for
|
||||
movb $0x00,%bh # bios video call
|
||||
|
Loading…
Reference in New Issue
Block a user