Finished Part I, moved part 2 relavent files to own folder.
This commit is contained in:
11
Part2/A4/05_basic_int/kernel/kernel.c
Executable file
11
Part2/A4/05_basic_int/kernel/kernel.c
Executable file
@@ -0,0 +1,11 @@
|
||||
#include "../drivers/screen.h"
|
||||
#include "util.h"
|
||||
#include "../cpu/isr.h"
|
||||
#include "../cpu/idt.h"
|
||||
|
||||
void _start() {
|
||||
isr_install();
|
||||
/* Test the interrupts */
|
||||
__asm__ __volatile__("int $2");
|
||||
__asm__ __volatile__("int $3");
|
||||
}
|
30
Part2/A4/05_basic_int/kernel/util.c
Executable file
30
Part2/A4/05_basic_int/kernel/util.c
Executable file
@@ -0,0 +1,30 @@
|
||||
#include "util.h"
|
||||
|
||||
void memory_copy(char *source, char *dest, int nbytes) {
|
||||
int i;
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
*(dest + i) = *(source + i);
|
||||
}
|
||||
}
|
||||
|
||||
void memory_set(u8 *dest, u8 val, u32 len) {
|
||||
u8 *temp = (u8 *)dest;
|
||||
for ( ; len != 0; len--) *temp++ = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* K&R implementation
|
||||
*/
|
||||
void int_to_ascii(int n, char str[]) {
|
||||
int i, sign;
|
||||
if ((sign = n) < 0) n = -n;
|
||||
i = 0;
|
||||
do {
|
||||
str[i++] = n % 10 + '0';
|
||||
} while ((n /= 10) > 0);
|
||||
|
||||
if (sign < 0) str[i++] = '-';
|
||||
str[i] = '\0';
|
||||
|
||||
/* TODO: implement "reverse" */
|
||||
}
|
10
Part2/A4/05_basic_int/kernel/util.h
Executable file
10
Part2/A4/05_basic_int/kernel/util.h
Executable file
@@ -0,0 +1,10 @@
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include "../cpu/types.h"
|
||||
|
||||
void memory_copy(char *source, char *dest, int nbytes);
|
||||
void memory_set(u8 *dest, u8 val, u32 len);
|
||||
void int_to_ascii(int n, char str[]);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user