Skip to content

Commit

Permalink
Add boot_finished(), to aid in setting simics bookmarks post-boot
Browse files Browse the repository at this point in the history
  • Loading branch information
exscape committed Dec 7, 2014
1 parent e13aeda commit bfbbf49
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions initrd/etc/shrc
@@ -0,0 +1,6 @@
#!/bin/sh

# Auto-execute commands on /bin/sh startup

# ls -R bin etc
# scandir
17 changes: 16 additions & 1 deletion src/kernel/kshell.c
Expand Up @@ -342,6 +342,12 @@ extern list_t *ext2_partitions;
char *ext2_read_file(ext2_partition_t *part, uint32 inode_num, uint32 *size);
uint16 internet_checksum(void *data, uint32 len);

// Debugging helpers (for setting breakpoints post-boot, in simics)
int shells_started = 0;
void boot_finished(void) {
return;
}

void kshell(void *data, uint32 length) {
unsigned char *buf = kmalloc(1024);
memset(buf, 0, 1024);
Expand All @@ -357,7 +363,16 @@ void kshell(void *data, uint32 length) {
assert(strlen((char *)current_task->name) >= 8 && strncmp((char *)current_task->name, "[kshell]", 8) == 0);

// Hack: start the userspace shell automatically
task = create_task_elf("/bin/sh", current_task->console, (char *)"/bin/sh", strlen("/bin/sh"));
if (current_task->console == &kernel_console) {
task = create_task_elf("/bin/sh", current_task->console, (char *)"/bin/sh", strlen("/bin/sh"));
}

shells_started++;

if (shells_started == 3) {
sleep(500);
boot_finished(); // No-op to help debugging
}

while (true) {
// Wait until the "child" task is still running
Expand Down

0 comments on commit bfbbf49

Please sign in to comment.