mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:57:36 +00:00
Add a sys$exit and make init_stage2 call it when finished.
This commit is contained in:
parent
79ffdb7205
commit
3a3c57357c
5 changed files with 35 additions and 3 deletions
|
@ -77,6 +77,10 @@ DWORD handle(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3)
|
||||||
return current->sys$kill((pid_t)arg1, (int)arg2);
|
return current->sys$kill((pid_t)arg1, (int)arg2);
|
||||||
case Syscall::PosixGetuid:
|
case Syscall::PosixGetuid:
|
||||||
return current->sys$getuid();
|
return current->sys$getuid();
|
||||||
|
case Syscall::PosixExit:
|
||||||
|
current->sys$exit((int)arg1);
|
||||||
|
ASSERT_NOT_REACHED();
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
kprintf("int0x80: Unknown function %x requested {%x, %x, %x}\n", function, arg1, arg2, arg3);
|
kprintf("int0x80: Unknown function %x requested {%x, %x, %x}\n", function, arg1, arg2, arg3);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,6 +16,7 @@ enum Function {
|
||||||
PosixSeek = 0x1988,
|
PosixSeek = 0x1988,
|
||||||
PosixKill = 0x1989,
|
PosixKill = 0x1989,
|
||||||
PosixGetuid = 0x1990,
|
PosixGetuid = 0x1990,
|
||||||
|
PosixExit = 0x1991,
|
||||||
};
|
};
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
@ -23,21 +24,21 @@ void initialize();
|
||||||
inline DWORD invoke(DWORD function)
|
inline DWORD invoke(DWORD function)
|
||||||
{
|
{
|
||||||
DWORD result;
|
DWORD result;
|
||||||
asm("int $0x80":"=a"(result):"a"(function));
|
asm volatile("int $0x80":"=a"(result):"a"(function));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DWORD invoke(DWORD function, DWORD arg1)
|
inline DWORD invoke(DWORD function, DWORD arg1)
|
||||||
{
|
{
|
||||||
DWORD result;
|
DWORD result;
|
||||||
asm("int $0x80":"=a"(result):"a"(function),"d"(arg1));
|
asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DWORD invoke(DWORD function, DWORD arg1, DWORD arg2)
|
inline DWORD invoke(DWORD function, DWORD arg1, DWORD arg2)
|
||||||
{
|
{
|
||||||
DWORD result;
|
DWORD result;
|
||||||
asm("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2));
|
asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,26 @@ void Task::dumpRegions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Task::sys$exit(int status)
|
||||||
|
{
|
||||||
|
cli();
|
||||||
|
kprintf("sys$exit: %s(%u) exit with status %d\n", name().characters(), pid(), status);
|
||||||
|
|
||||||
|
setState(Exiting);
|
||||||
|
dumpRegions();
|
||||||
|
|
||||||
|
s_tasks->remove(this);
|
||||||
|
|
||||||
|
if (!scheduleNewTask()) {
|
||||||
|
kprintf("Task::taskDidCrash: Failed to schedule a new task :(\n");
|
||||||
|
HANG;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete this;
|
||||||
|
|
||||||
|
switchNow();
|
||||||
|
}
|
||||||
|
|
||||||
void Task::taskDidCrash(Task* crashedTask)
|
void Task::taskDidCrash(Task* crashedTask)
|
||||||
{
|
{
|
||||||
// NOTE: This is called from an excepton handler, so interrupts are disabled.
|
// NOTE: This is called from an excepton handler, so interrupts are disabled.
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
BlockedSleep = 5,
|
BlockedSleep = 5,
|
||||||
Terminated = 6,
|
Terminated = 6,
|
||||||
Crashing = 7,
|
Crashing = 7,
|
||||||
|
Exiting = 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RingLevel {
|
enum RingLevel {
|
||||||
|
@ -83,6 +84,7 @@ public:
|
||||||
int sys$kill(pid_t pid, int sig);
|
int sys$kill(pid_t pid, int sig);
|
||||||
int sys$geterror() { return m_error; }
|
int sys$geterror() { return m_error; }
|
||||||
void sys$sleep(DWORD ticks);
|
void sys$sleep(DWORD ticks);
|
||||||
|
void sys$exit(int status);
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -192,6 +192,11 @@ static void init_stage2()
|
||||||
|
|
||||||
kprintf("init stage2 is done!\n");
|
kprintf("init stage2 is done!\n");
|
||||||
|
|
||||||
|
DO_SYSCALL_A1(Syscall::PosixExit, 413);
|
||||||
|
|
||||||
|
kprintf("uh, we're still going after calling sys$exit...\n");
|
||||||
|
HANG;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
asm("hlt");
|
asm("hlt");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue