Skip to content
This repository has been archived by the owner on Aug 2, 2018. It is now read-only.

Commit

Permalink
mark panic and stop functions as noreturn, use HalShutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
temoto committed Apr 10, 2011
1 parent 0829654 commit f6dbf33
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/k411/hal/hal.h
Expand Up @@ -11,7 +11,7 @@
void HalPreInit(void);
void HalInit(void);
void HalBreak(void);
void HalShutdown(void);
noreturn HalShutdown(void);
void HalReboot(void);

#endif /* end of include guard: HAL_H */
4 changes: 2 additions & 2 deletions include/k411/panic.h
Expand Up @@ -17,7 +17,7 @@ struct stack_frame {

void panic_dump_hex(unsigned int *stack);
char *stop_getmsg(int error);
void stop(int error, int argc, ...);
noreturn stop(int error, int argc, ...);
void stop_dump_stack(void);
void stack_dump(void);
void register_dump(void);
Expand All @@ -29,7 +29,7 @@ void assert_dowork(const char *function, const char *file, int line, const char
#define assert(a) if (!(a)) assert_dowork(__FUNCTION__, __FILE__, __LINE__, #a)

/* Panic */
void _panic(char *text, const char *function, const char *filename, int line);
noreturn _panic(char *text, const char *function, const char *filename, int line);
#define panic(message) _panic(message, __FUNCTION__, __FILE__, __LINE__)

#endif /* end of include guard: PANIC_H */
17 changes: 7 additions & 10 deletions kernel/panic.c
Expand Up @@ -12,13 +12,12 @@ char *stop_table[7] = {
(char*)0x0
};

void _panic(char *text, const char *function, const char *filename, int line)
noreturn _panic(char *text, const char *function, const char *filename, int line)
{
if (in_panic) {
/* Something is causing a recursive panic, so
* just kill the machine. */
__asm volatile("cli");
__asm volatile("hlt");
HalShutdown();
}
in_panic = 1;

Expand All @@ -28,8 +27,8 @@ void _panic(char *text, const char *function, const char *filename, int line)
printf("\n**** UDUDD ***\n\n%s\n\n", text);
printf("Function: %s\nFile: %s\nLine: %d\n", function, filename, line);
stack_dump();
__asm("cli");
__asm("hlt");

HalShutdown();
}

void panic_dump_hex(unsigned int *stack)
Expand Down Expand Up @@ -61,7 +60,7 @@ char *stop_getmsg(int error)
return (char*)stop_table[index+1];
}

void stop(int error, int argc, ...)
noreturn stop(int error, int argc, ...)
{
va_list ap;
int i;
Expand All @@ -72,8 +71,7 @@ void stop(int error, int argc, ...)
if (in_panic) {
/* Something is causing a recursive stop, so
* just kill the machine. */
__asm volatile("cli");
__asm volatile("hlt");
HalShutdown();
}
in_panic = 1;

Expand Down Expand Up @@ -116,8 +114,7 @@ void stop(int error, int argc, ...)

stop_dump_stack();

__asm volatile("cli");
__asm volatile("hlt");
HalShutdown();
}

void assert_dowork(const char *function, const char *file, int line, const char *code)
Expand Down

0 comments on commit f6dbf33

Please sign in to comment.