Draft: lab 5 failed

This commit is contained in:
2025-05-03 20:45:34 +08:00
parent 981cae803b
commit e73f90395d
39 changed files with 588 additions and 429 deletions

View File

@@ -97,7 +97,7 @@ int isupper(int c)
int32_t atoi32(const char *s)
{
if (!s)
exit(ERR_CONVERSION);
panic(ERR_CONVERSION);
int is_neg = 0;
if (*s != '\0' && *s == '-')
@@ -106,7 +106,7 @@ int32_t atoi32(const char *s)
int32_t ret = 0;
for (; *s != '\0'; ++s) {
if (!isdigit(*s))
exit(ERR_CONVERSION);
panic(ERR_CONVERSION);
ret *= 10, ret += *s - '0';
}
@@ -116,12 +116,12 @@ int32_t atoi32(const char *s)
uint32_t atoh32(const char *s)
{
if (!s)
exit(ERR_CONVERSION);
panic(ERR_CONVERSION);
uint32_t ret = 0;
for (int i = 8; i-- && *s != '\0'; ++s) {
if (!isxdigit(*s))
exit(ERR_CONVERSION);
panic(ERR_CONVERSION);
ret <<= 4, ret |= (isdigit(*s) ? *s - '0' :
(isupper(*s) ? *s - 'A' + 10 :
*s - 'a' + 10));
@@ -130,7 +130,7 @@ uint32_t atoh32(const char *s)
return ret;
}
void exit(int exit_code)
void panic(int exitcode)
{
static int print = 0;
if (!print) {
@@ -138,14 +138,14 @@ void exit(int exit_code)
"OOPS! YOUR KERNEL DEAD" ENDL
"ERROR CODE: "
);
uart_hex(exit_code);
uart_hex(exitcode);
uart_puts(ENDL);
print = 1;
}
asm volatile(
"wfe\n"
"b exit"
"b panic"
);
__builtin_unreachable();
}