add CatchAllDebugBucket as a syscall for debugging, add a basic network card plus ethernet driver (wip)
This commit is contained in:
1 parent
bf34d63ea3
commit
0d7f71b693
22 files changed
+2248
-25
No files matched your search
@@ -24,6 +24,32 @@ static void printInt(int32_t n) {
|
||||
else { printUInt((uint32_t)n); }
|
||||
}
|
||||
|
||||
static uint64_t parseUInt64(const char* s) {
|
||||
uint64_t v = 0;
|
||||
while (*s == ' ') s++;
|
||||
while (*s >= '0' && *s <= '9') v = v * 10 + (uint64_t)(*s++ - '0');
|
||||
return v;
|
||||
}
|
||||
|
||||
// Parse up to 6 comma-separated uint64 values.
|
||||
// Returns the number of values actually parsed.
|
||||
static int parseArgs(const char* line, uint64_t args[6]) {
|
||||
int count = 0;
|
||||
while (*line && count < 6) {
|
||||
args[count++] = parseUInt64(line);
|
||||
while (*line && *line != ',') line++; // skip to next comma
|
||||
if (*line == ',') line++; // consume comma
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static void printUInt64(uint64_t n) {
|
||||
if (n == 0) { print("0"); return; }
|
||||
char buf[20]; int i = 0;
|
||||
while (n > 0) { buf[i++] = (char)('0' + (int)(n % 10)); n /= 10; }
|
||||
while (i > 0) { char c[2] = { buf[--i], '\0' }; print(c); }
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Line editor
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -54,6 +80,7 @@ static char* trim(char* s) {
|
||||
static void cmd_help() {
|
||||
print("Available commands:\n"
|
||||
" help - Show this list\n"
|
||||
" debug - Enter debug bucket mode\n"
|
||||
" dir [path] - List directory contents\n"
|
||||
" cd <path> - Change directory\n"
|
||||
" type <file> - Display file contents\n"
|
||||
@@ -63,6 +90,32 @@ static void cmd_help() {
|
||||
" exit - Close the shell\n");
|
||||
}
|
||||
|
||||
static void cmd_debug(void) {
|
||||
print("Entered debug mode. Type args as: a0,a1,a2,a3,a4,a5\n");
|
||||
print("Type 'exit' to leave.\n");
|
||||
|
||||
char line[MAX_CMD];
|
||||
while (true) {
|
||||
print("debug> ");
|
||||
readLine(line, MAX_CMD);
|
||||
char* t = trim(line);
|
||||
|
||||
if (strcmp(t, "exit") == 0) {
|
||||
print("Exit debug.\n");
|
||||
break;
|
||||
}
|
||||
if (*t == '\0') continue;
|
||||
|
||||
uint64_t args[6] = {0, 0, 0, 0, 0, 0};
|
||||
parseArgs(t, args);
|
||||
|
||||
uint64_t ret = SysCatchAllDebugBucket(args[0], args[1], args[2],
|
||||
args[3], args[4], args[5]);
|
||||
printUInt64(ret);
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_write(const char* args) {
|
||||
char filename[MAX_CMD]; int i = 0;
|
||||
while (args[i] != ' ' && args[i] != '\0' && i < MAX_CMD - 1) {
|
||||
@@ -150,6 +203,7 @@ static int runCommand(const char* cmd) {
|
||||
if (strcmp(cmd, "help") == 0) { cmd_help(); return 0; }
|
||||
if (strcmp(cmd, "clear") == 0) { SysScreenClear(0); return 0; }
|
||||
if (strcmp(cmd, "crash") == 0) { *(int*)0 = 42; return 0; }
|
||||
if (strcmp(cmd, "debug") == 0) { cmd_debug(); return 0; }
|
||||
if (strcmp(cmd, "dir") == 0) { cmd_dir("."); return 0; }
|
||||
if (strncmp(cmd, "dir ", 4) == 0) { cmd_dir(cmd + 4); return 0; }
|
||||
if (strncmp(cmd, "cd ", 3) == 0) { if (SysSetCwd(cmd + 3) != 0) print("cd: failed\n"); return 0; }
|
||||
|
||||
Reference in new issue
Block a user