Fix UTM display: remove required framebuffer tag, add serial output, ls app
Display fixes for UTM/Mac black screen issue:
- Remove MULTIBOOT_HEADER_TAG_FRAMEBUFFER from multiboot2 header (was required,
requesting text mode depth=0 which confused GRUB on some platforms)
- Add COM1 serial port (0x3F8) output alongside debugcon for UTM serial capture
- Change VGA background from black to dark blue for diagnostics
- Add early canary write to 0xB8000 ('COS' in magenta) before subsystem init
- print_hex now outputs to both debugcon and COM1
New ls command and SYS_READDIR syscall:
- SYS_READDIR (10): reads directory entries via VFS
- VFS root listing: vfs_readdir handles '/' by iterating mount table
- apps/ls: lists CWD contents, appends '/' for directories
- apps/libc/syscalls.h: readdir() wrapper
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "env.h"
|
||||
#include "port_io.h"
|
||||
#include "vga.h"
|
||||
#include "vfs.h"
|
||||
#include "keyboard.h"
|
||||
#include "cpio.h"
|
||||
#include "paging.h"
|
||||
@@ -281,6 +282,30 @@ static int32_t sys_setenv(registers_t *regs) {
|
||||
return env_set(&cur->env, key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle SYS_READDIR: read a directory entry.
|
||||
* EBX = path, ECX = index, EDX = name buffer (128 bytes min).
|
||||
* Returns entry type (VFS_FILE=1, VFS_DIRECTORY=2, ...) on success, -1 at end.
|
||||
*/
|
||||
static int32_t sys_readdir(registers_t *regs) {
|
||||
const char *path = (const char *)regs->ebx;
|
||||
uint32_t idx = regs->ecx;
|
||||
char *name_buf = (char *)regs->edx;
|
||||
|
||||
vfs_dirent_t entry;
|
||||
if (vfs_readdir(path, idx, &entry) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Copy entry name to user buffer */
|
||||
uint32_t len = strlen(entry.name);
|
||||
if (len >= 128) len = 127;
|
||||
memcpy(name_buf, entry.name, len);
|
||||
name_buf[len] = '\0';
|
||||
|
||||
return (int32_t)entry.type;
|
||||
}
|
||||
|
||||
/** System call dispatch table. */
|
||||
typedef int32_t (*syscall_fn)(registers_t *);
|
||||
static syscall_fn syscall_table[NUM_SYSCALLS] = {
|
||||
@@ -294,6 +319,7 @@ static syscall_fn syscall_table[NUM_SYSCALLS] = {
|
||||
[SYS_EXEC] = sys_exec,
|
||||
[SYS_GETENV] = sys_getenv,
|
||||
[SYS_SETENV] = sys_setenv,
|
||||
[SYS_READDIR] = sys_readdir,
|
||||
};
|
||||
|
||||
void syscall_handler(registers_t *regs) {
|
||||
|
||||
Reference in New Issue
Block a user