Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update kernel.c #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,20 @@ void readSector(byte* buf, int sector) {
);
}

// TODO: 1. Implement writeSector function
void writeSector(byte* buf, int sector) {}
// Implement writeSector function
void writeSector(byte* buf, int sector) {
int ah = 0x03; // write sector service number
int al = 0x01; // number of sectors to write
int ch = div(sector, 36); // cylinder number
int cl = mod(sector, 18) + 1; // sector number
int dh = mod(div(sector, 18), 2); // head number
int dl = 0x00; // drive number

interrupt(
0x13,
ah << 8 | al,
buf,
ch << 8 | cl,
dh << 8 | dl
);
}