summaryrefslogtreecommitdiff
path: root/lib/klibc.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-03-27 11:39:12 -0400
committerFreya Murphy <freya@freyacat.org>2025-03-27 11:39:12 -0400
commit0ff301cda68669c59351e5854ce98f2cf460543f (patch)
treecfe8f976261962420ada64b821559b9da0a56841 /lib/klibc.c
parentadd compile_flags.txt for clangd lsp (diff)
downloadcomus-0ff301cda68669c59351e5854ce98f2cf460543f.tar.gz
comus-0ff301cda68669c59351e5854ce98f2cf460543f.tar.bz2
comus-0ff301cda68669c59351e5854ce98f2cf460543f.zip
pull upstream changes, add auto formatting
Diffstat (limited to 'lib/klibc.c')
-rw-r--r--lib/klibc.c63
1 files changed, 31 insertions, 32 deletions
diff --git a/lib/klibc.c b/lib/klibc.c
index ded0c78..6a06a96 100644
--- a/lib/klibc.c
+++ b/lib/klibc.c
@@ -23,12 +23,12 @@
**
** @param ch The character to be printed
*/
-void put_char_or_code( int ch ) {
-
- if( ch >= ' ' && ch < 0x7f ) {
- cio_putchar( ch );
+void put_char_or_code(int ch)
+{
+ if (ch >= ' ' && ch < 0x7f) {
+ cio_putchar(ch);
} else {
- cio_printf( "\\x%02x", ch );
+ cio_printf("\\x%02x", ch);
}
}
@@ -40,30 +40,29 @@ void put_char_or_code( int ch ) {
** @param ebp Initial EBP to use
** @param args Number of function argument values to print
*/
-void backtrace( uint32_t *ebp, uint_t args ) {
-
- cio_puts( "Trace: " );
- if( ebp == NULL ) {
- cio_puts( "NULL ebp, no trace possible\n" );
+void backtrace(uint32_t *ebp, uint_t args)
+{
+ cio_puts("Trace: ");
+ if (ebp == NULL) {
+ cio_puts("NULL ebp, no trace possible\n");
return;
} else {
- cio_putchar( '\n' );
+ cio_putchar('\n');
}
- while( ebp != NULL ){
-
+ while (ebp != NULL) {
// get return address and report it and EBP
uint32_t ret = ebp[1];
- cio_printf( " ebp %08x ret %08x args", (uint32_t) ebp, ret );
+ cio_printf(" ebp %08x ret %08x args", (uint32_t)ebp, ret);
// print the requested number of function arguments
- for( uint_t i = 0; i < args; ++i ) {
- cio_printf( " [%u] %08x", i+1, ebp[2+i] );
+ for (uint_t i = 0; i < args; ++i) {
+ cio_printf(" [%u] %08x", i + 1, ebp[2 + i]);
}
- cio_putchar( '\n' );
+ cio_putchar('\n');
// follow the chain
- ebp = (uint32_t *) *ebp;
+ ebp = (uint32_t *)*ebp;
}
}
@@ -78,35 +77,35 @@ void backtrace( uint32_t *ebp, uint_t args ) {
** @param msg[in] String containing a relevant message to be printed,
** or NULL
*/
-void kpanic( const char *msg ) {
-
- cio_puts( "\n\n***** KERNEL PANIC *****\n\n" );
+void kpanic(const char *msg)
+{
+ cio_puts("\n\n***** KERNEL PANIC *****\n\n");
- if( msg ) {
- cio_printf( "%s\n", msg );
+ if (msg) {
+ cio_printf("%s\n", msg);
}
- delay( DELAY_5_SEC ); // approximately
+ delay(DELAY_5_SEC); // approximately
// dump a bunch of potentially useful information
// dump the contents of the current PCB
- pcb_dump( "Current", current, true );
+ pcb_dump("Current", current, true);
// dump the basic info about what's in the process table
ptable_dump_counts();
// dump information about the queues
- pcb_queue_dump( "R", ready, true );
- pcb_queue_dump( "W", waiting, true );
- pcb_queue_dump( "S", sleeping, true );
- pcb_queue_dump( "Z", zombie, true );
- pcb_queue_dump( "I", sioread, true );
+ pcb_queue_dump("R", ready, true);
+ pcb_queue_dump("W", waiting, true);
+ pcb_queue_dump("S", sleeping, true);
+ pcb_queue_dump("Z", zombie, true);
+ pcb_queue_dump("I", sioread, true);
// perform a stack backtrace
- backtrace( (uint32_t *) r_ebp(), 3 );
+ backtrace((uint32_t *)r_ebp(), 3);
// could dump other stuff here, too
- panic( "KERNEL PANIC" );
+ panic("KERNEL PANIC");
}