void print_le_named(const char *name,const char *mem,int size) { kprint(name); kprint(" "); print_le(mem,size); kprint("\r\n"); }
void kprintInt(char filler,int amount,int x){ if (x == 0) { kprint(48); return; } if (x<0) { kprint('-'); x = x*-1; //make it positive! } int base = 1000000000; int length = 10; bool nonZero = false; //find first 10^x that is smaller then the number while (base>=1) { int temp = x/base; if (temp != 0) break; else { base/=10; length--; } } unsigned char output[20]; //unsigned char *output = (unsigned char*)kmalloc(sizeof(char)*length); base = 10; for(int i = length-1;i>=0;i--){ output[i] = x%10; x = (x-(x%10)) / 10; } for(int i = 0;i<length;i++) kprint(output[i]+48); }
/*! Display info on threads */ int k_thread_info () { kthread_t *kthr; int i = 1; kprint ( "Threads info\n" ); kprint ( "[this]\tid=%d in process at %x, size=%d\n", active_thread->id, active_thread->proc->m.start, active_thread->proc->m.size ); kprint ( "\tprio=%d, state=%d, ret_val=%d\n", active_thread->sched.prio, active_thread->state, active_thread->exit_status ); kthr = list_get ( &all_threads, FIRST ); while ( kthr ) { kprint ( "[%d]\tid=%d in process at %x, size=%d\n", i++, kthr->id, kthr->proc->m.start, kthr->proc->m.size ); kprint ( "\tprio=%d, state=%d, ret_val=%d\n", kthr->sched.prio, kthr->state, kthr->exit_status ); kthr = list_get_next ( &kthr->all ); } return 0; }
/*! * First kernel function (after grub loads it to memory) * \param magic Multiboot magic number * \param addr Address where multiboot structure is saved */ void k_startup ( unsigned long magic, unsigned long addr ) { extern console_t STDOUT; /* default stdout for kernel */ extern console_t STDOUT_PROG; /* default stdout for programs */ /* initialize 'stdout' for kernel */ k_stdout = &STDOUT; /* or, for example: extern console_t dev_null; k_stdout = &dev_null; */ k_stdout->init ( NULL ); /* initialize 'stdout' for programs */ u_stdout = &STDOUT_PROG; u_stdout->init ( NULL ); kprint ( "%s\n", system_info ); /* "programs" - select programs to run */ kprint ( "\nStarting program: hello_world\n\n" ); hello_world (); #ifdef DEBUG kprint ( "\nLOG, ASSERT* test\n" ); debug_output_test (); #endif kprint ( "\nSystem halted!" ); halt (); }
static int page_chunk_init(phys_area_info* elem, kmem_chunk* next , kmem_chunk* prev) { kmem_chunk* a_begin = elem->begin; kmem_chunk* a_end = elem->end - sizeof(kmem_chunk) + 1; if (elem == NULL) kdie("page_chunk_init: elem == NULL"); a_begin->prev = prev; a_begin->next = a_end; a_begin->size = 0; a_begin->area_size = AREA_SIZE(elem); a_end->next = next; a_end->prev = a_begin; a_end->size = 0; a_end->area_size = 0; #ifdef TEDIOS_MAL_DEBUG kprint("Area is initialized.\r\n" "Begin chunk:\r\n"); kmem_chunk_dump(a_begin); kprint("End chunk:\r\n"); kmem_chunk_dump(a_end); #endif return 0; }
void syscalls_install(void) { char syscall_ascii[2] = ""; int_to_ascii(num_syscalls, syscall_ascii); kprint("\n[+] Initializing syscall table with ", 0x07); kprint(syscall_ascii, 0x08); kprint(" functions\n", 0x07); }
int main(int argc, char *argv[]) { for (int i = 1; i < argc; i++) { if (i > 1) kprint(" "); kprint(argv[i]); } kprint("\n"); return 0; }
void isr_handler(registers_t *r) { kprint("received interrupt: "); char s[3]; int_to_ascii(r->int_no, s); kprint(s); kprint("\n"); kprint(exception_messages[r->int_no]); kprint("\n"); }
int main(int argc, char *argv[]) { kprint("^^^ REDIRTEST_CHILD START\n"); printf("redir child, I just talk to stdout\n"); char *line = "redir_child, I just talk to stderr\n"; write(stderr_fd, line, strlen(line)); kprint("^^^ REDIRTEST_CHILD END\n"); return 0; }
void sch_DumpIDT( void ) { int i = 0; DWORD *addr = (DWORD *)0x00120000; for (i=0; i<20; i++) { kprintDWORD(*addr++); kprint(" "); kprintDWORD(*addr++); kprint("\n"); } }
static void timer_callback(registers_t *regs) { (void) regs; tick++; kprint("Tick: "); kprint_int(regs->int_no); kprint(" "); kprint_int(tick); kprint("\r"); }
/*! * First kernel function (after grub loads it to memory) * \param magic Multiboot magic number * \param addr Address where multiboot structure is saved */ void k_startup ( unsigned long magic, unsigned long addr ) { arch_console_init (); kprint ( "%s\n", system_info ); /* "programs" - select programs to run */ kprint ( "\nStarting program: hello_world\n\n" ); hello_world (); kprint ( "\nSystem halted!" ); halt (); }
void usb_on() { volatile u32* mailbox; u32 result; mailbox = (u32*)(IO_BASE + 0x0000B880); while (mailbox[6] & 0x80000000); mailbox[8] = 0x80; do { while (mailbox[6] & 0x40000000); } while (((result = mailbox[0]) & 0xf) != 0); (result == 0x80) ? kprint("USB OK\n") : kprint("USB ERROR\n"); }
/*! * First kernel function (after grub loads it to memory) * \param magic Multiboot magic number * \param addr Address where multiboot structure is saved */ void k_startup ( unsigned long magic, unsigned long addr ) { extern console_t INITIAL_STDOUT; /* initial stdout */ extern console_t STDOUT; /* default stdout for kernel */ extern console_t STDOUT_PROG; /* default stdout for programs */ /* set initial stdout */ k_stdout = &INITIAL_STDOUT; k_stdout->init ( NULL ); /* initialize memory subsystem (needed for boot) */ k_memory_init ( magic, addr ); /* start with regular initialization */ /* interrupts */ arch_init_interrupts (); /* timer subsystem */ k_time_init (); /* switch to default 'stdout' for kernel */ //extern console_t dev_null; //k_stdout = &dev_null; k_stdout = &STDOUT; k_stdout->init( NULL ); /* initialize 'stdout' for programs */ u_stdout = &STDOUT_PROG; u_stdout->init ( NULL ); kprint ( "%s\n", system_info ); enable_interrupts (); /* "programs" - select programs to run */ // kprint ( "\nStarting program: hello_world\n\n" ); // hello_world (); // kprint ( "\nStarting program: timer\n\n" ); // timer (); //kprint ( "\nStarting program: dmem\n\n" ); //dmem (); kprint ( "\nStarting program: bftest\n\n" ); labos2test(); kprint ( "System halted!" ); halt(); }
void sch_DumpKernelTSS( void ) { int i = 0; DWORD *addr = (DWORD *)0x00121000; for (i=0; i<7; i++) { kprintDWORD(*addr++); kprint(" "); kprintDWORD(*addr++); kprint(" "); kprintDWORD(*addr++); kprint(" "); kprintDWORD(*addr++); kprint("\n"); } addr = (DWORD *)0x00124000; for (i=0; i<7; i++) { kprintDWORD(*addr++); kprint(" "); kprintDWORD(*addr++); kprint(" "); kprintDWORD(*addr++); kprint(" "); kprintDWORD(*addr++); kprint("\n"); } }
void kernel_main(multiboot_info_t* mbd,unsigned int magic) { /* Initialization */ terminal_initialize(); kprint("Kernel Loading...\nInitializing GDT......"); gdt_install(); kprint("DONE\nInitializing IDT......"); idt_install(); kprint("DONE\n"); total_memory=mbd->mem_upper; total_memory*=1024; enter_pmode(); }
void kmain( void* mbd, unsigned int magic ) { if ( magic != 0x2BADB002 ) { /* Something went not according to specs. Print an error */ /* msg and halt, but do *not* rely on the multiboot */ /* data structure. */ } /* Print a letter to screen to see everything is working: */ kprint("\a\a\a"); kclrscr(); /*clearing screen */ kprint("Hi! \n Ankit is too \t coooool, YOOOOOOO",12); }
int main(int argc, char *argv[]) { int id = my_id(); char buf[8]; sprintf(buf, "+%d\n", id); kprint(buf); process_create(PROGRAM); process_create(PROGRAM); sprintf(buf, "-%d\n", id); kprint(buf); return 0; }
void k_main(multiboot_info_t *mbd, unsigned int magic) { if(magic != MULTIBOOT_BOOTLOADER_MAGIC) { return; } init_early_console(); if(!(mbd->flags & 0x01)) { kprint("The bootloader isn't giving us any memory information\n"); kprint("Terminating execution!\n"); } kprint("Kernel size: "); kprint_hex((&kernel_end - &kernel_start) * sizeof(int), 8); kprint(" Bytes\n"); init_physpage_map(); parse_mb_map(mbd); }
void kprintf(kshell_t *ksh, const char *fmt, ...) { va_list args; va_start(args, fmt); kprint(ksh, fmt, args); va_end(args); }
/*-- Cat pdnet;RPC;Jabber-RPC Form int JabberRPC_Init(); Description Init function for Jabber-RPC. --*/ int JabberRPC_Init() { XMPP_Interface *xmpp_if; NET_Interface *net_if; kprint("Jabber-RPC: Init\n"); //jabber-rpc xmpp_if=XMPP_CreateInterface("jabber:iq:rpc"); xmpp_if->iq=&jabberrpc_iq; net_if=NET_CreateInterface("jabber-rpc"); net_if->decode_url=&jabberrpc_decode_url; net_if->encode_url=&jabberrpc_encode_url; net_if->rpc_call=&jabberrpc_rpc_call; //bgbrpc-jid xmpp_if=XMPP_CreateInterface("http://bgb-sys.sourceforge.net/bgb-rpc"); xmpp_if->iq=&jabberrpc_iq; net_if=NET_CreateInterface("bgbrpc-jid"); net_if->decode_url=&jabberrpc_decode_url; net_if->encode_url=&jabberrpc_encode_url; net_if->rpc_call=&jabberrpc_rpc_call; return(0); }
int _getpid (int n) { kprint("W] call getpid\n"); return 1; n = n; }
int _rename (const char * oldpath, const char * newpath) { kprint("W] call rename\n"); errno = ENOSYS; return -1; }
LUA_API void lua_callk (lua_State *L, int nargs, int nresults, int ctx, lua_CFunction k) { StkId func; //kprint("LUA:lock\n"); lua_lock(L); //kprint("LUA:achk1\n"); api_check(L, k == NULL || !isLua(L->ci), "cannot use continuations inside hooks"); kprint("LUA:chelems\n"); api_checknelems(L, nargs+1); //kprint("LUA:achk2\n"); api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); //kprint("LUA:chres\n"); checkresults(L, nargs, nresults); func = L->top - (nargs+1); if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ L->ci->u.c.k = k; /* save continuation */ L->ci->u.c.ctx = ctx; /* save context */ //kprint("LUA:call1!\n"); luaD_call(L, func, nresults, 1); /* do the call */ } else /* no continuation or no yieldable */ {luaD_call(L, func, nresults, 0); /* just do the call */} //kprint("LUA:some adjust\n"); adjustresults(L, nresults); //kprint("LUA:unlock\n"); lua_unlock(L); //kprint("LUA:unlocked\n"); }
void kernel_main() { isr_install(); irq_install(); kprint("Type something, it will go through the kernel\n" "Type END to halt the CPU\n> "); }
/*! * Init memory layout: using variables "from" linker script and multiboot info */ void k_memory_init ( unsigned long magic, unsigned long addr ) { extern char kernel_code, k_kernel_end; multiboot_info_t *mbi; /* implicitly from kernel linker script */ k_kernel.start = &kernel_code; k_kernel.size = ( (uint) &k_kernel_end ) - (uint) &kernel_code; /* Am I booted by a Multiboot-compliant boot loader? */ if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { kprint ( "Boot loader is not multiboot-compliant!\n" ); halt(); } /* from multiboot info */ multiboot = addr; mbi = (void *) addr; k_heap.start = (void *) &k_kernel_end; k_heap.size = ( mbi->mem_upper - 1024 ) * 1024 - (size_t) &k_kernel_end; /* initialize dynamic memory allocation subsystem (needed for boot) */ k_mpool = k_mem_init ( k_heap.start, k_heap.size ); }
static void task2() { while (1) { kprint("I AM TASK 2\r"); swtch(&tsk2->context, tsk1->context); } }
void listDir(struct fs_node* nodeDir,int level){ int i = 0; struct dirent* node = 0; while ((node=readdir_fs(nodeDir,i))!=0){ fs_node* fsnode = finddir_fs(nodeDir,node->name); for(int i = 0;i<level;i++) kprintf(" "); if (fsnode != NULL){ if ((fsnode->flags&0x7)==FS_DIRECTORY){ kprintf("[%s]\n",trim(fsnode->name)); if (fsnode->name[0]!='.') listDir(fsnode,level+1); } else if ((fsnode->flags&0x1)==FS_FILE){ kprintf("%s\n",fsnode->name); char buf[256]; kprintf("----\n"); unsigned x = 0; while(1==1){ unsigned int sz = read_fs(fsnode,0+x,256,buf); x+=256; if (sz != 0){ for(unsigned int i = 0;i<sz;i++) kprint(buf[i]); } else break; } kprintf("\n----\n"); } //kprintf("\n"); } i++; } }
unsigned char floppy_read(unsigned short port) { int counter=0; unsigned char in=0; while(((inb(FP_MAIN_STATUS_REGISTER) & 0x80)==0)) { if(counter>=90) { kprint("\nFloppy Lesezugriff Zeitueberschreitung\n"); break; } counter++; timerSleep(10); } //kprint("\nFloppy Daten gelesen\n"); timerSleep(1); waitIO(); in=inb(FP_DATA_FIFO); waitIO(); return in; }
void kprintf(char* format, ...) { register char* f = format; register char** varg = (&format) + 7; // Why 7? I don't know, it just works while (*f) { if (*f == '%') { char buf[64]; f++; if (*f == 's') { kprint(*varg); varg += 1; } else if (*f == 'd') { itoa(*((int*) varg), buf, 10); kprint(buf); varg += sizeof(int); } else if (*f == 'x') { itoa(*((int*) varg), buf, 16); kprint(buf); varg += sizeof(int); } } else { kputc(*f); } f++; } }