Added kprintln and memset
This commit is contained in:
parent
070de9c196
commit
6a020aeeee
|
@ -41,6 +41,7 @@ limitations under the License.
|
||||||
void clearScreen(void);
|
void clearScreen(void);
|
||||||
void kprintAt(char* message, i32 col, i32 row);
|
void kprintAt(char* message, i32 col, i32 row);
|
||||||
void kprint(char* message);
|
void kprint(char* message);
|
||||||
|
void kprintln(char* message);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -22,7 +22,13 @@ limitations under the License.
|
||||||
#define true 1
|
#define true 1
|
||||||
#define false 0
|
#define false 0
|
||||||
|
|
||||||
typedef unsigned char byte;
|
// Some of these are duplicates, but their meaning
|
||||||
|
// is purely contextual (to make it clearer what is
|
||||||
|
// what in a given function)
|
||||||
|
|
||||||
|
typedef char i8;
|
||||||
|
typedef char byte;
|
||||||
|
typedef unsigned char u8;
|
||||||
typedef unsigned short int u16;
|
typedef unsigned short int u16;
|
||||||
typedef short int i16;
|
typedef short int i16;
|
||||||
typedef unsigned int u32;
|
typedef unsigned int u32;
|
||||||
|
|
|
@ -20,6 +20,7 @@ limitations under the License.
|
||||||
#include "kernel/types.h"
|
#include "kernel/types.h"
|
||||||
|
|
||||||
void copystr(const char* source, char* dest, i32 n);
|
void copystr(const char* source, char* dest, i32 n);
|
||||||
void itoa(i32 i, char* a);
|
void memset(u8* dest, u8 val, u32 len);
|
||||||
|
void itoa(const i32 i, char* a);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -58,7 +58,7 @@ load_kernel: ; Loads the kernel into memory
|
||||||
mov si, loading_kernel_msg
|
mov si, loading_kernel_msg
|
||||||
call bios_println
|
call bios_println
|
||||||
mov bx, kernel_offset
|
mov bx, kernel_offset
|
||||||
mov dh, 3
|
mov dh, 4
|
||||||
mov dl, [boot_drive]
|
mov dl, [boot_drive]
|
||||||
call load_disk
|
call load_disk
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -68,6 +68,15 @@ void kprint(char* message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void inline kprintln(char* message) {
|
||||||
|
/*
|
||||||
|
Identical to kprint, but calls
|
||||||
|
kprint("\n") afterwards
|
||||||
|
*/
|
||||||
|
kprint(message);
|
||||||
|
kprint("\n");
|
||||||
|
}
|
||||||
|
|
||||||
// Private API below
|
// Private API below
|
||||||
|
|
||||||
i32 putchar(byte ch, i32 col, i32 row, byte attr) {
|
i32 putchar(byte ch, i32 col, i32 row, byte attr) {
|
||||||
|
|
|
@ -24,9 +24,9 @@ i32 kmain(void) {
|
||||||
The kernel entry point of TSOS
|
The kernel entry point of TSOS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Newline so we skip the log
|
// We skip the log messages from
|
||||||
// messages from the bootloader
|
// the bootloader
|
||||||
kprint("\nTSOS: Kernel load OK");
|
kprintln("\n\n\n\nTSOS: Kernel load OK");
|
||||||
// TODO...
|
// TODO...
|
||||||
return 0x022172; // :D
|
return 0x022172; // :D
|
||||||
}
|
}
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
#include "kernel/types.h"
|
#include "kernel/types.h"
|
||||||
#include "kernel/util.h"
|
#include "kernel/util.h"
|
||||||
|
|
||||||
|
|
||||||
void copystr(const char* restrict source, char* restrict dest, i32 n) {
|
void copystr(const char* restrict source, char* restrict dest, i32 n) {
|
||||||
/*
|
/*
|
||||||
Copies n bytes from source to dest. The two memory locations may
|
Copies n bytes from source to dest. The two memory locations may
|
||||||
|
@ -34,6 +35,18 @@ void copystr(const char* restrict source, char* restrict dest, i32 n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void memset(u8* dest, u8 val, u32 len) {
|
||||||
|
/*
|
||||||
|
Implementation for memset
|
||||||
|
*/
|
||||||
|
u8* temp = (u8*)dest;
|
||||||
|
while (len) {
|
||||||
|
*temp++ = val;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
i32 countDigits(i32 n) {
|
i32 countDigits(i32 n) {
|
||||||
/*
|
/*
|
||||||
Returns the number of digits
|
Returns the number of digits
|
||||||
|
|
Loading…
Reference in New Issue