Basic debugger support over serial

This commit is contained in:
Ali Mashtizadeh 2014-07-13 13:36:43 -07:00
parent dd0e90c84d
commit c9750e4834
6 changed files with 55 additions and 7 deletions

View File

@ -11,6 +11,7 @@ src_amd64 = [
"amd64/multiboot.S", "amd64/multiboot.S",
"amd64/mbentry.c", "amd64/mbentry.c",
# AMD64 # AMD64
"amd64/debug.c",
"amd64/trap.c", "amd64/trap.c",
"amd64/trapentry.S", "amd64/trapentry.S",
"amd64/machine.c", "amd64/machine.c",

View File

@ -3,7 +3,7 @@
#include <kassert.h> #include <kassert.h>
#include <kconfig.h> #include <kconfig.h>
//#include <kdebug.h> #include <kdebug.h>
#include <mp.h> #include <mp.h>
#include "trap.h" #include "trap.h"

View File

@ -29,9 +29,31 @@ Console_LateInit()
Serial_LateInit(); Serial_LateInit();
} }
void char
Console_Getc(char ch) Console_Getc()
{ {
return Serial_Getc();
}
void
Console_Gets(char *str, size_t n)
{
int i;
for (i = 0; i < (n - 1); i++)
{
char ch = Console_Getc();
if (ch == '\r')
{
Console_Putc('\n');
str[i] = '\0';
return;
}
Console_Putc(ch);
str[i] = ch;
}
str[i+1] = '\0';
} }
void void

View File

@ -3,6 +3,8 @@
#define __CONSOLE_H__ #define __CONSOLE_H__
void Console_Init(); void Console_Init();
char Console_Getc();
void Console_Gets(char *str, size_t n);
void Console_Putc(char ch); void Console_Putc(char ch);
void Console_Puts(const char *str); void Console_Puts(const char *str);

13
sys/include/kdebug.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef __KDEBUG_H__
#define __KDEBUG_H__
// Platform Functions
void Debug_Registers(int argc, const char *argv[]);
// Generic Functions
void Debug_Dump(int argc, const char *argv[]);
void Debug_Prompt();
#endif /* __KDEBUG_H__ */

View File

@ -18,6 +18,9 @@
#include <stdint.h> #include <stdint.h>
#include <kassert.h> #include <kassert.h>
#include <kdebug.h>
#include "../dev/console.h"
void void
Debug_PrintHex(const char *data, size_t length, off_t off, size_t limit) Debug_PrintHex(const char *data, size_t length, off_t off, size_t limit)
@ -75,16 +78,23 @@ Debug_Dump(int argc, const char *argv[])
{ {
} }
#define DEBUG_MAX_LINE 128
void void
Debug_Prompt() Debug_Prompt()
{ {
char buf[DEBUG_MAX_LINE];
kprintf("Entered Debugger!\n"); kprintf("Entered Debugger!\n");
kprintf("> "); while (1) {
// read input kprintf("> ");
// parse input // read input
Console_Gets(&buf, DEBUG_MAX_LINE);
// execute command // parse input
// execute command
}
} }