}
.bss ALIGN(4): {
_bss_start = .;
- _bss_start_off = _bss_start - _kern_start;
* (.bss*);
* (COMMON);
. = ALIGN(4);
extern _bootsect_start
extern _kern_start_seg
+extern _kern_start
extern _kern_size
boot_driveno equ 0500h
jnz .rdloop
; loaded sucessfully, load segment registers and jump
-.done: mov ax, _kern_start_seg
+.done: xor ax, ax
mov ds, ax
mov es, ax
push ax
- xor ax, ax
+ mov ax, _kern_start
push ax
retf
static struct file *devfile;
+extern int in_panic;
+
void con_init(void)
{
+#if CONDEV != DEV_VID
if(!(devfile = dev_open(CONDEV, 0, O_RDWR))) {
panic("can't open console device %d,%d\n", CONDEV, 0);
}
+#endif
}
void con_putchar(int c)
{
if(devfile) {
- vid_putchar(c); /* XXX dbg */
- //devfile->dev->fop->write(devfile, &c, 1);
+ if(in_panic) {
+ vid_putchar(c);
+ }
+ devfile->dev->fop->write(devfile, &c, 1);
} else {
vid_putchar(c);
}
#define VERSTR "v0.0"
/* CONDEV: which device to use for the kernel console (DEV_VID or DEV_SER) */
-#define CONDEV DEV_SER
+#define CONDEV DEV_VID
#endif /* CONFIG_H_ */
#include "dbg.h"
#include "asmutil.h"
+int in_panic;
+
__attribute__((noreturn))
void panic(const char *fmt, ...)
{
struct wordregs regs;
struct segregs sregs;
+ in_panic = 1;
+
getregs(®s);
regs.ip = getip(); /* replace ip with the caller's */
getsregs(&sregs);
for(;;) halt();
}
+
+void dbgping(int c)
+{
+ unsigned short __far *vmem = MK_FP(0xb800, 0);
+ vmem[79] = c | 0xc00;
+}
__attribute__((noreturn))
void panic(const char *fmt, ...);
+void dbgping(int c);
+
+#define dbgbreak() asm volatile("int $3")
+
#endif /* DBG_H_ */
struct file *dev_open(int major, int minor, unsigned int flags)
{
/* XXX temporary hack */
- struct inode fakenode;
+ static struct inode fakenode;
static struct file file;
fakenode.dev_major = major;
if(!devices[major].fop) {
return 0;
}
- printf("dev_open(%x, %x, %x)\n", major, minor, flags);
if(devices[major].fop->open(&file, &fakenode, flags) < 0) {
- panic("open failed");
return 0;
}
- panic("WTF");
-
return &file;
}
{
int port = inode->dev_minor;
- panic("ser_open");
-
if(port < 0 || port >= 2) {
return -ENXIO;
}
{
int port = file->inode->dev_minor;
unsigned char *ptr = buf;
- while(sz > 0) {
+
+ while(sz-- > 0) {
serput(port, *ptr++);
}
return ptr - (unsigned char*)buf;
STACKSZ equ 4096
extern kmain
-extern _bss_start_off
+extern _bss_start
extern _bss_size
global _start
xor ax, ax
mov sp, ax
+ mov ds, ax
+ mov es, ax
+ mov ss, ax
+
; zero .bss
- mov di, _bss_start_off
+ mov di, _bss_start
mov cx, _bss_size
shr cx, 1
rep stosw
- xor ax, ax
- mov es, ax
call kmain