added include/portio.h; using it to update cursor position in kputc()
git-svn-id: svn://anubis/hos/trunk@55 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
parent
1dd8250048
commit
08af04897c
37
kernel/include/portio.h
Executable file
37
kernel/include/portio.h
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
#ifndef PORTIO_H
|
||||||
|
#define PORTIO_H
|
||||||
|
|
||||||
|
#include "hos_types.h"
|
||||||
|
|
||||||
|
#define outportb(port, val) \
|
||||||
|
__asm__ __volatile__ ("outb %%al, %%dx" : : "a" (val), "d" (port));
|
||||||
|
|
||||||
|
#define outportw(port, val) \
|
||||||
|
__asm__ __volatile__ ("outw %%ax, %%dx" : : "a" (val), "d" (port));
|
||||||
|
|
||||||
|
#define outportd(port, val) \
|
||||||
|
__asm__ __volatile__ ("outl %%eax, %%dx" : : "a" (val), "d" (port));
|
||||||
|
|
||||||
|
#define inportb(port) \
|
||||||
|
({ \
|
||||||
|
u8_t val; \
|
||||||
|
__asm__ __volatile__ ("inb %%dx, %%al" : "=a" (val) : "d" (port)); \
|
||||||
|
val; \
|
||||||
|
});
|
||||||
|
|
||||||
|
#define inportw(port) \
|
||||||
|
({ \
|
||||||
|
u16_t val; \
|
||||||
|
__asm__ __volatile__ ("inw %%dx, %%al" : "=a" (val) : "d" (port)); \
|
||||||
|
val; \
|
||||||
|
});
|
||||||
|
|
||||||
|
#define inportd(port) \
|
||||||
|
({ \
|
||||||
|
u32_t val; \
|
||||||
|
__asm__ __volatile__ ("inl %%dx, %%al" : "=a" (val) : "d" (port)); \
|
||||||
|
val; \
|
||||||
|
});
|
||||||
|
|
||||||
|
#endif
|
@ -3,6 +3,7 @@
|
|||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
#include "kio.h"
|
#include "kio.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
#include "portio.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdarg.h> /* va_*() */
|
#include <stdarg.h> /* va_*() */
|
||||||
@ -17,12 +18,22 @@ static void fmt_o2a(char * buf, unsigned int val);
|
|||||||
|
|
||||||
static int cursor_x, cursor_y;
|
static int cursor_x, cursor_y;
|
||||||
|
|
||||||
|
static void writeCursorPosition(int x, int y)
|
||||||
|
{
|
||||||
|
u16_t pos = 80 * y + x;
|
||||||
|
outportb(0x3D4, 0x0E);
|
||||||
|
outportb(0x3D5, pos >> 8);
|
||||||
|
outportb(0x3D4, 0x0F);
|
||||||
|
outportb(0x3D5, pos);
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
void kio_bootstrap()
|
void kio_bootstrap()
|
||||||
{
|
{
|
||||||
cursor_x = 0;
|
cursor_x = 0;
|
||||||
cursor_y = 9;
|
cursor_y = 9;
|
||||||
|
writeCursorPosition(cursor_x, cursor_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kprintf(const char * fmt, ...)
|
void kprintf(const char * fmt, ...)
|
||||||
@ -129,7 +140,9 @@ void kputc(char c)
|
|||||||
(u8_t *) (CONSOLE_MEMORY + 80 * 2),
|
(u8_t *) (CONSOLE_MEMORY + 80 * 2),
|
||||||
2 * 80 * 24);
|
2 * 80 * 24);
|
||||||
memsetw((u16_t *) (CONSOLE_MEMORY + 2 * 80 * 24), 0x0720, 80);
|
memsetw((u16_t *) (CONSOLE_MEMORY + 2 * 80 * 24), 0x0720, 80);
|
||||||
|
cursor_y = 24;
|
||||||
}
|
}
|
||||||
|
writeCursorPosition(cursor_x, cursor_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kputs(const char * s)
|
void kputs(const char * s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user