mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-04 02:23:10 +00:00
Began work on tty driver
This commit is contained in:
+15
-2
@@ -18,7 +18,20 @@
|
|||||||
#define __naked __attribute__((naked))
|
#define __naked __attribute__((naked))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utility macros
|
* Standard int types
|
||||||
*/
|
*/
|
||||||
#define sizeof_array(_a) ()
|
// Unsigned
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
typedef unsigned long uint64_t;
|
||||||
|
// Signed
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef signed short int16_t;
|
||||||
|
typedef signed int int32_t;
|
||||||
|
typedef signed long int64_t;
|
||||||
|
// Size
|
||||||
|
typedef uint32_t size_t;
|
||||||
|
typedef int32_t ssize_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
#ifndef _TTY_H
|
#ifndef _TTY_H
|
||||||
#define _TTY_H
|
#define _TTY_H
|
||||||
|
|
||||||
|
/* VGA Text mode */
|
||||||
|
#define VGA_WIDTH 80
|
||||||
|
#define VGA_HEIGHT 25
|
||||||
|
#define VGA_MEMORY 0xb8000
|
||||||
|
|
||||||
int tty_init(void);
|
int tty_init(void);
|
||||||
int tty_write(char* buf, size_t len);
|
int tty_write(char* buf, size_t len);
|
||||||
int tty_putc(char c);
|
int tty_putc(char c);
|
||||||
|
|||||||
+3
-2
@@ -1,8 +1,9 @@
|
|||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
|
#include <tty.h>
|
||||||
|
|
||||||
__noreturn
|
__noreturn
|
||||||
void kmain(void) {
|
void kmain(void) {
|
||||||
*(char*)0xb8000 = 'a';
|
tty_init();
|
||||||
while (1) __asm__ volatile ("movl $69, %eax");
|
printk("Hello, World!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#include <kernel.h>
|
||||||
|
#include <tty.h>
|
||||||
|
|
||||||
|
struct {
|
||||||
|
size_t row;
|
||||||
|
size_t col;
|
||||||
|
uint8_t attr;
|
||||||
|
uint8_t* buf;
|
||||||
|
} ctx;
|
||||||
|
|
||||||
|
void tty_init(void) {
|
||||||
|
ctx.row = 0;
|
||||||
|
ctx.col = 0;
|
||||||
|
ctx.attr = 0x07;
|
||||||
|
ctx.buf = (u8*)VGA_MEMORY;
|
||||||
|
|
||||||
|
for (size_t y = 0; y < VGA_HEIGHT; y++) {
|
||||||
|
for (size_t x = 0; x < VGA_WIDTH; x++) {
|
||||||
|
size_t i = (y * VGA_WIDTH + x) * 2;
|
||||||
|
ctx.buf[i] = ' ';
|
||||||
|
ctx.buf[i + 1] = ctx.attr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int tty_write(char* buf, size_t len) {}
|
||||||
|
|
||||||
|
int tty_putc(char c) {}
|
||||||
|
|
||||||
|
int tty_puts(char* s) {}
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ clean:
|
|||||||
|
|
||||||
qemu:
|
qemu:
|
||||||
qemu-system-x86_64\
|
qemu-system-x86_64\
|
||||||
-drive format=raw,file=$(IMG),index=0,media=disk\
|
-kernel ./kernel/kernel.elf
|
||||||
-m 256M -accel tcg -monitor stdio -net none\
|
-m 256M -accel tcg -monitor stdio -net none\
|
||||||
-rtc base=localtime,clock=host,driftfix=slew\
|
-rtc base=localtime,clock=host,driftfix=slew\
|
||||||
-audiodev pipewire,id=audio0 -machine pcspk-audiodev=audio0
|
-audiodev pipewire,id=audio0 -machine pcspk-audiodev=audio0
|
||||||
|
|||||||
Reference in New Issue
Block a user