Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 98a9300

Browse filesBrowse files
committed
And we got 539filesystem! Is this the last part of 539kernel? :-)
1 parent d0e48fd commit 98a9300
Copy full SHA for 98a9300

9 files changed

+370-63Lines changed: 370 additions & 63 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Makefile‎

Copy file name to clipboardExpand all lines: src/Makefile
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ kernel: $(BOOTSTRAP_FILE) $(KERNEL_FILE)
5959
$(CC) $(KERNEL_FLAGS) heap.c -o heap.elf
6060
$(CC) $(KERNEL_FLAGS) paging.c -o paging.elf
6161
$(CC) $(KERNEL_FLAGS) ata.c -o ata.elf
62+
$(CC) $(KERNEL_FLAGS) str.c -o str.elf
6263
$(CC) $(KERNEL_FLAGS) filesystem.c -o filesystem.elf
63-
ld -melf_i386 -Tlinker.ld starter.o kernel.elf screen.elf process.elf scheduler.elf heap.elf paging.elf ata.elf filesystem.elf -o 539kernel.elf
64+
ld -melf_i386 -Tlinker.ld starter.o kernel.elf screen.elf process.elf scheduler.elf heap.elf paging.elf ata.elf str.elf filesystem.elf -o 539kernel.elf
6465
objcopy -O binary 539kernel.elf 539kernel.bin
6566
dd if=bootstrap.o of=kernel.img
66-
dd seek=1 conv=sync if=539kernel.bin of=kernel.img bs=512 count=10
67-
dd seek=11 conv=sync if=/dev/zero of=kernel.img bs=512 count=2046
67+
dd seek=1 conv=sync if=539kernel.bin of=kernel.img bs=512 count=20
68+
dd seek=21 conv=sync if=/dev/zero of=kernel.img bs=512 count=2046
6869
#bochs -f bochs
6970
qemu-system-x86_64 -s kernel.img
7071

@@ -78,12 +79,13 @@ debug: $(BOOTSTRAP_FILE) $(KERNEL_FILE)
7879
$(CC) $(KERNEL_FLAGS) heap.c -o heap.elf
7980
$(CC) $(KERNEL_FLAGS) paging.c -o paging.elf
8081
$(CC) $(KERNEL_FLAGS) ata.c -o ata.elf
82+
$(CC) $(KERNEL_FLAGS) str.c -o str.elf
8183
$(CC) $(KERNEL_FLAGS) filesystem.c -o filesystem.elf
82-
ld -melf_i386 -Tlinker.ld starter.o kernel.elf screen.elf process.elf scheduler.elf heap.elf paging.elf ata.elf filesystem.elf -o 539kernel.elf
84+
ld -melf_i386 -Tlinker.ld starter.o kernel.elf screen.elf process.elf scheduler.elf heap.elf paging.elf ata.elf str.elf filesystem.elf -o 539kernel.elf
8385
objcopy -O binary 539kernel.elf 539kernel.bin
8486
dd if=bootstrap.o of=kernel.img
85-
dd seek=1 conv=sync if=539kernel.bin of=kernel.img bs=512 count=9
86-
dd seek=10 conv=sync if=/dev/zero of=kernel.img bs=512 count=2045
87+
dd seek=1 conv=sync if=539kernel.bin of=kernel.img bs=512 count=20
88+
dd seek=21 conv=sync if=/dev/zero of=kernel.img bs=512 count=2045
8789
bochs -f bochs
8890

8991
rerun-debug:
Collapse file

‎src/ata.c‎

Copy file name to clipboardExpand all lines: src/ata.c
+23-25Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#include "ata.h"
22

3+
void wait_drive_until_ready()
4+
{
5+
int status = 0;
6+
7+
do
8+
{
9+
status = dev_read( BASE_PORT + 7 );
10+
} while ( ( status ^ 0x80 ) == 128 );
11+
}
12+
313
// LBA
414
void *read_disk( int address )
515
{
@@ -11,13 +21,8 @@ void *read_disk( int address )
1121
dev_write( BASE_PORT + 7, 0x20 ); // Command: Read with Retry
1222

1323
// ... //
14-
15-
int status = 0;
1624

17-
do
18-
{
19-
status = dev_read( BASE_PORT + 7 ) ;
20-
} while ( ( status ^ 0x80 ) == 128 );
25+
wait_drive_until_ready();
2126

2227
// ... //
2328

@@ -31,25 +36,20 @@ void *read_disk( int address )
3136

3237
// LBA
3338
void write_disk( int address, short *buffer )
34-
{
39+
{
3540
dev_write( BASE_PORT + 6, ( 0x0e0 | ( ( address & 0x0F000000 ) >> 24 ) ) ); // Drive 0. Bits 0-3 = Bits 24-27 of LBA
3641
dev_write( BASE_PORT + 2, 1 ); // Sector count
3742
dev_write( BASE_PORT + 3, address & 0x000000FF ); // LBA's 0-7 bits
3843
dev_write( BASE_PORT + 4, ( address & 0x0000FF00 ) >> 8 ); // LBA's 8-15 bits
3944
dev_write( BASE_PORT + 5, ( address & 0x00FF0000 ) >> 16 ); // LBA's 16-23 bits
4045
dev_write( BASE_PORT + 7, 0x30 ); // Command: Write with Retry
4146

42-
//int status = 0;
43-
44-
do
45-
{
46-
status = dev_read( BASE_PORT + 7 ) ;
47-
} while ( ( status ^ 0x80 ) == 128 );
48-
49-
// ... //
47+
wait_drive_until_ready();
5048

5149
for ( int currByte = 0; currByte < ( SECTOR_SIZE / 2 ); currByte++ )
5250
dev_write_word( BASE_PORT, buffer[ currByte ] );
51+
52+
wait_drive_until_ready();
5353
}
5454

5555

@@ -62,12 +62,9 @@ void *read_disk_chs( int sector )
6262
dev_write( BASE_PORT + 5, 0 ); // Cylinder - High
6363
dev_write( BASE_PORT + 7, 0x20 ); // Command: Read with Retry
6464

65-
int status = 0;
65+
// ... //
6666

67-
do
68-
{
69-
status = dev_read( BASE_PORT + 7 );
70-
} while ( ( status ^ 0x80 ) == 128 );
67+
wait_drive_until_ready();
7168

7269
// ... //
7370

@@ -88,17 +85,18 @@ void write_disk_chs( int sector, short *buffer )
8885
dev_write( BASE_PORT + 5, 0 ); // Cylinder - High
8986
dev_write( BASE_PORT + 7, 0x30 ); // Command: Write with Retry
9087

91-
int status = 0;
88+
// ... //
9289

93-
do
94-
{
95-
status = dev_read( BASE_PORT + 7 ) ;
96-
} while ( ( status ^ 0x80 ) == 128 );
90+
wait_drive_until_ready();
9791

9892
// ... //
9993

10094
for ( int currByte = 0; currByte < ( SECTOR_SIZE / 2 ); currByte++ )
10195
dev_write_word( BASE_PORT, buffer[ currByte ] );
96+
97+
// ... //
98+
99+
wait_drive_until_ready();
102100
}
103101

104102

Collapse file

‎src/bootstrap.asm‎

Copy file name to clipboardExpand all lines: src/bootstrap.asm
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ printing_finished:
158158
title_string db 'The Bootloader of 539kernel.', 0
159159
message_string db 'The kernel is loading...', 0
160160
load_error_string db 'The kernel cannot be loaded', 0
161-
number_of_sectors_to_load db 10d ; 255 sectors = 127.5KB ; [MQH] NEW 4 July 2021
161+
number_of_sectors_to_load db 15d ; 255 sectors = 127.5KB ; [MQH] NEW 4 July 2021
162162
curr_sector_to_load db 2d
163163

164164
; [MQH] 9 Dec 2019

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.