This commit is contained in:
Garen Chan 2023-09-30 21:46:20 -03:00 committed by GitHub
commit 767a01cbd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 46 deletions

View File

@ -6,7 +6,7 @@
static void keyboard_callback(registers_t regs) { static void keyboard_callback(registers_t regs) {
/* The PIC leaves us the scancode in port 0x60 */ /* The PIC leaves us the scancode in port 0x60 */
u8 scancode = port_byte_in(0x60); u8 scancode = port_byte_in(0x60);
char *sc_ascii; char sc_ascii[4];
int_to_ascii(scancode, sc_ascii); int_to_ascii(scancode, sc_ascii);
kprint("Keyboard scancode: "); kprint("Keyboard scancode: ");
kprint(sc_ascii); kprint(sc_ascii);
@ -99,24 +99,24 @@ void print_letter(u8 scancode) {
case 0x19: case 0x19:
kprint("P"); kprint("P");
break; break;
case 0x1A: case 0x1A:
kprint("["); kprint("[");
break; break;
case 0x1B: case 0x1B:
kprint("]"); kprint("]");
break; break;
case 0x1C: case 0x1C:
kprint("ENTER"); kprint("ENTER");
break; break;
case 0x1D: case 0x1D:
kprint("LCtrl"); kprint("LCtrl");
break; break;
case 0x1E: case 0x1E:
kprint("A"); kprint("A");
break; break;
case 0x1F: case 0x1F:
kprint("S"); kprint("S");
break; break;
case 0x20: case 0x20:
kprint("D"); kprint("D");
break; break;
@ -147,24 +147,24 @@ void print_letter(u8 scancode) {
case 0x29: case 0x29:
kprint("`"); kprint("`");
break; break;
case 0x2A: case 0x2A:
kprint("LShift"); kprint("LShift");
break; break;
case 0x2B: case 0x2B:
kprint("\\"); kprint("\\");
break; break;
case 0x2C: case 0x2C:
kprint("Z"); kprint("Z");
break; break;
case 0x2D: case 0x2D:
kprint("X"); kprint("X");
break; break;
case 0x2E: case 0x2E:
kprint("C"); kprint("C");
break; break;
case 0x2F: case 0x2F:
kprint("V"); kprint("V");
break; break;
case 0x30: case 0x30:
kprint("B"); kprint("B");
break; break;

View File

@ -18,7 +18,7 @@ Right now we have a `utils.c` which we will split into `mem.c` and `string.c`, w
Second, we will create a new function `irq_install()` so that the kernel Second, we will create a new function `irq_install()` so that the kernel
only needs to perform one call to initialize all the IRQs. That function only needs to perform one call to initialize all the IRQs. That function
is akin to `isr_install()` and placed on the same `irq.c`. is akin to `isr_install()` and placed on the same `isr.c`.
While we're here, we will disable the `kprint()` on `timer_callback()` While we're here, we will disable the `kprint()` on `timer_callback()`
to avoid filling the screen with junk, now that we know that it works to avoid filling the screen with junk, now that we know that it works
properly. properly.

View File

@ -1,5 +1,5 @@
#ifndef STRINGS_H #ifndef STRING_H
#define STRINGS_H #define STRING_H
void int_to_ascii(int n, char str[]); void int_to_ascii(int n, char str[]);
void reverse(char s[]); void reverse(char s[]);

View File

@ -15,7 +15,7 @@ our first page starts at 0x10000 (as hardcoded on `mem.c`) and
subsequent `kmalloc()`'s produce a new address which is subsequent `kmalloc()`'s produce a new address which is
aligned 4096 bytes or 0x1000 from the previous one. aligned 4096 bytes or 0x1000 from the previous one.
Note that we added a new `strings.c:hex_to_ascii()` for Note that we added a new `string.c:hex_to_ascii()` for
nicer printing of hex numbers. nicer printing of hex numbers.
Another cosmetic modification is to rename `types.c` to Another cosmetic modification is to rename `types.c` to

View File

@ -1,5 +1,5 @@
#ifndef STRINGS_H #ifndef STRING_H
#define STRINGS_H #define STRING_H
void int_to_ascii(int n, char str[]); void int_to_ascii(int n, char str[]);
void hex_to_ascii(int n, char str[]); void hex_to_ascii(int n, char str[]);

View File

@ -79,7 +79,7 @@ We add `cld` just before `call isr_handler` on `cpu/interrupt.asm` as suggested
by the osdev wiki. by the osdev wiki.
There is a final, important issue with `cpu/interrupt.asm`. The common stubs create an instance There is a final, important issue with `cpu/interrupt.asm`. The common stubs create an instance
of `struct registers` on the stack and then call the C handler. But that breaks the ABI, since of `struct registers_t` on the stack and then call the C handler. But that breaks the ABI, since
the stack belongs to the called function and they may change them as they please. It is needed the stack belongs to the called function and they may change them as they please. It is needed
to pass the struct as a pointer. to pass the struct as a pointer.

View File

@ -1,5 +1,5 @@
#ifndef STRINGS_H #ifndef STRING_H
#define STRINGS_H #define STRING_H
void int_to_ascii(int n, char str[]); void int_to_ascii(int n, char str[]);
void hex_to_ascii(int n, char str[]); void hex_to_ascii(int n, char str[]);