bool dbg_hw_info(void) { int line; lcd_clear_display(); lcd_setfont(FONT_SYSFIXED); while(1) { lcd_clear_display(); line = 0; /* _DEBUG_PRINTF statements can be added here to show debug info */ _DEBUG_PRINTF("SCU_ID: 0x%0x", SCU_ID); _DEBUG_PRINTF("SCU_PLLCON1: 0x%0x", SCU_PLLCON1); _DEBUG_PRINTF("SCU_PLLCON2: 0x%0x", SCU_PLLCON2); _DEBUG_PRINTF("SCU_PLLCON3: 0x%0x", SCU_PLLCON3); _DEBUG_PRINTF("SCU_DIVCON1: 0x%0x", SCU_DIVCON1); _DEBUG_PRINTF("SCU_CLKCFG: 0x%0x", SCU_CLKCFG); _DEBUG_PRINTF("SCU_CHIPCFG: 0x%0x", SCU_CHIPCFG); line++; _DEBUG_PRINTF("sd_debug_time_rd: %d", sd_debug_time_rd); _DEBUG_PRINTF("sd_debug_time_wr: %d", sd_debug_time_wr); lcd_update(); switch(button_get_w_tmo(HZ/20)) { case DEBUG_CANCEL: case BUTTON_REL: lcd_setfont(FONT_UI); return false; } } lcd_setfont(FONT_UI); return false; }
pid_t sys_exec(const char *cmdline) { _DEBUG_PRINTF ("[DEBUG] Exec : %s\n", cmdline); // cmdline is an address to the character buffer, on user memory // so a validation check is required check_user((const uint8_t*) cmdline); lock_acquire (&filesys_lock); // load() uses filesystem pid_t pid = process_execute(cmdline); lock_release (&filesys_lock); return pid; }
bool dbg_hw_info(void) { int line; int i; unsigned int state = 0; const unsigned int max_states=3; lcd_clear_display(); lcd_setfont(FONT_SYSFIXED); state=0; while(1) { lcd_clear_display(); line = 0; if(state == 0) { _DEBUG_PRINTF("CPU:"); _DEBUG_PRINTF("current_tick: %d", (unsigned int)current_tick); line++; _DEBUG_PRINTF("LCD type: %d", lcd_type); line++; } else if(state==1) { _DEBUG_PRINTF("PMU:"); for(i=0;i<7;i++) { char *device[] = {"(unknown)", "(unknown)", "(unknown)", "(unknown)", "(unknown)", "(unknown)", "(unknown)"}; _DEBUG_PRINTF("ldo%d %s: %dmV %s",i, pmu_read(0x2e + (i << 1))?" on":"off", 900 + pmu_read(0x2d + (i << 1))*100, device[i]); } _DEBUG_PRINTF("cpu voltage: %dmV",625 + pmu_read(0x1e)*25); _DEBUG_PRINTF("memory voltage: %dmV",625 + pmu_read(0x22)*25); line++; _DEBUG_PRINTF("charging: %s", charging_state() ? "true" : "false"); _DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off"); _DEBUG_PRINTF("brightness value: %d", pmu_read(0x28)); } else if(state==2) { _DEBUG_PRINTF("Audio DMA:"); _DEBUG_PRINTF(">%08X %08X %08X %08X %08X", DMAC0C0CONFIG, DMAC0C0SRCADDR, DMAC0C0DESTADDR, DMAC0C0NEXTLLI, DMAC0C0CONTROL); for(i = 0; i < PCM_LLICOUNT; i++) _DEBUG_PRINTF("%08X: %08X %08X %08X %08X", &pcm_lli[i], pcm_lli[i].srcaddr, pcm_lli[i].dstaddr, pcm_lli[i].nextlli, pcm_lli[i].control); _DEBUG_PRINTF("chunk: %08X %08X", pcm_chunksize, pcm_remaining); } else { state=0; } lcd_update(); switch(button_get_w_tmo(HZ/20)) { case BUTTON_SCROLL_BACK: if(state!=0) state--; break; case BUTTON_SCROLL_FWD: if(state!=max_states-1) { state++; } break; case DEBUG_CANCEL: case BUTTON_REL: lcd_setfont(FONT_UI); return false; } } lcd_setfont(FONT_UI); return false; }
bool dbg_ports(void) { int line; lcd_setfont(FONT_SYSFIXED); while(1) { lcd_clear_display(); line = 0; _DEBUG_PRINTF("GPIO 0: %08x",(unsigned int)PDAT(0)); _DEBUG_PRINTF("GPIO 1: %08x",(unsigned int)PDAT(1)); _DEBUG_PRINTF("GPIO 2: %08x",(unsigned int)PDAT(2)); _DEBUG_PRINTF("GPIO 3: %08x",(unsigned int)PDAT(3)); _DEBUG_PRINTF("GPIO 4: %08x",(unsigned int)PDAT(4)); _DEBUG_PRINTF("GPIO 5: %08x",(unsigned int)PDAT(5)); _DEBUG_PRINTF("GPIO 6: %08x",(unsigned int)PDAT(6)); _DEBUG_PRINTF("GPIO 7: %08x",(unsigned int)PDAT(7)); _DEBUG_PRINTF("GPIO 8: %08x",(unsigned int)PDAT(8)); _DEBUG_PRINTF("GPIO 9: %08x",(unsigned int)PDAT(9)); _DEBUG_PRINTF("GPIO 10: %08x",(unsigned int)PDAT(10)); _DEBUG_PRINTF("GPIO 11: %08x",(unsigned int)PDAT(11)); _DEBUG_PRINTF("GPIO 12: %08x",(unsigned int)PDAT(12)); _DEBUG_PRINTF("GPIO 13: %08x",(unsigned int)PDAT(13)); _DEBUG_PRINTF("GPIO 14: %08x",(unsigned int)PDAT(14)); _DEBUG_PRINTF("GPIO 15: %08x",(unsigned int)PDAT(15)); _DEBUG_PRINTF("USEC : %08x",(unsigned int)USEC_TIMER); lcd_update(); if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) break; } lcd_setfont(FONT_UI); return false; }
static void syscall_handler (struct intr_frame *f) { int syscall_number; ASSERT( sizeof(syscall_number) == 4 ); // assuming x86 // The system call number is in the 32-bit word at the caller's stack pointer. memread_user(f->esp, &syscall_number, sizeof(syscall_number)); _DEBUG_PRINTF ("[DEBUG] system call, number = %d!\n", syscall_number); // Store the esp, which is needed in the page fault handler. // refer to exception.c:page_fault() (see manual 4.3.3) thread_current()->current_esp = f->esp; // Dispatch w.r.t system call number // SYS_*** constants are defined in syscall-nr.h switch (syscall_number) { case SYS_HALT: // 0 { sys_halt(); NOT_REACHED(); break; } case SYS_EXIT: // 1 { int exitcode; memread_user(f->esp + 4, &exitcode, sizeof(exitcode)); sys_exit(exitcode); NOT_REACHED(); break; } case SYS_EXEC: // 2 { void* cmdline; memread_user(f->esp + 4, &cmdline, sizeof(cmdline)); int return_code = sys_exec((const char*) cmdline); f->eax = (uint32_t) return_code; break; } case SYS_WAIT: // 3 { pid_t pid; memread_user(f->esp + 4, &pid, sizeof(pid_t)); int ret = sys_wait(pid); f->eax = (uint32_t) ret; break; } case SYS_CREATE: // 4 { const char* filename; unsigned initial_size; bool return_code; memread_user(f->esp + 4, &filename, sizeof(filename)); memread_user(f->esp + 8, &initial_size, sizeof(initial_size)); return_code = sys_create(filename, initial_size); f->eax = return_code; break; } case SYS_REMOVE: // 5 { const char* filename; bool return_code; memread_user(f->esp + 4, &filename, sizeof(filename)); return_code = sys_remove(filename); f->eax = return_code; break; } case SYS_OPEN: // 6 { const char* filename; int return_code; memread_user(f->esp + 4, &filename, sizeof(filename)); return_code = sys_open(filename); f->eax = return_code; break; } case SYS_FILESIZE: // 7 { int fd, return_code; memread_user(f->esp + 4, &fd, sizeof(fd)); return_code = sys_filesize(fd); f->eax = return_code; break; } case SYS_READ: // 8 { int fd, return_code; void *buffer; unsigned size; memread_user(f->esp + 4, &fd, sizeof(fd)); memread_user(f->esp + 8, &buffer, sizeof(buffer)); memread_user(f->esp + 12, &size, sizeof(size)); return_code = sys_read(fd, buffer, size); f->eax = (uint32_t) return_code; break; } case SYS_WRITE: // 9 { int fd, return_code; const void *buffer; unsigned size; memread_user(f->esp + 4, &fd, sizeof(fd)); memread_user(f->esp + 8, &buffer, sizeof(buffer)); memread_user(f->esp + 12, &size, sizeof(size)); return_code = sys_write(fd, buffer, size); f->eax = (uint32_t) return_code; break; } case SYS_SEEK: // 10 { int fd; unsigned position; memread_user(f->esp + 4, &fd, sizeof(fd)); memread_user(f->esp + 8, &position, sizeof(position)); sys_seek(fd, position); break; } case SYS_TELL: // 11 { int fd; unsigned return_code; memread_user(f->esp + 4, &fd, sizeof(fd)); return_code = sys_tell(fd); f->eax = (uint32_t) return_code; break; } case SYS_CLOSE: // 12 { int fd; memread_user(f->esp + 4, &fd, sizeof(fd)); sys_close(fd); break; } #ifdef VM case SYS_MMAP: // 13 { int fd; void *addr; memread_user(f->esp + 4, &fd, sizeof(fd)); memread_user(f->esp + 8, &addr, sizeof(addr)); mmapid_t ret = sys_mmap (fd, addr); f->eax = ret; break; } case SYS_MUNMAP: // 14 { mmapid_t mid; memread_user(f->esp + 4, &mid, sizeof(mid)); sys_munmap(mid); break; } #endif #ifdef FILESYS case SYS_CHDIR: // 15 { const char* filename; int return_code; memread_user(f->esp + 4, &filename, sizeof(filename)); return_code = sys_chdir(filename); f->eax = return_code; break; } case SYS_MKDIR: // 16 { const char* filename; int return_code; memread_user(f->esp + 4, &filename, sizeof(filename)); return_code = sys_mkdir(filename); f->eax = return_code; break; } case SYS_READDIR: // 17 { int fd; char *name; int return_code; memread_user(f->esp + 4, &fd, sizeof(fd)); memread_user(f->esp + 8, &name, sizeof(name)); return_code = sys_readdir(fd, name); f->eax = return_code; break; } case SYS_ISDIR: // 18 { int fd; int return_code; memread_user(f->esp + 4, &fd, sizeof(fd)); return_code = sys_isdir(fd); f->eax = return_code; break; } case SYS_INUMBER: // 19 { int fd; int return_code; memread_user(f->esp + 4, &fd, sizeof(fd)); return_code = sys_inumber(fd); f->eax = return_code; break; } #endif /* unhandled case */ default: printf("[ERROR] system call %d is unimplemented!\n", syscall_number); // ensure that waiting (parent) process should wake up and terminate. sys_exit(-1); break; } }
int sys_wait(pid_t pid) { _DEBUG_PRINTF ("[DEBUG] Wait : %d\n", pid); return process_wait(pid); }
bool dbg_ports(void) { int line; lcd_setfont(FONT_SYSFIXED); while(1) { lcd_clear_display(); line = 0; _DEBUG_PRINTF("GPIO_PADR: %02x",(unsigned char)GPIO_PADR); _DEBUG_PRINTF("GPIO_PACON: %02x",(unsigned char)GPIO_PACON); _DEBUG_PRINTF("GPIO_PBDR: %02x",(unsigned char)GPIO_PBDR); _DEBUG_PRINTF("GPIO_PBCON: %02x",(unsigned char)GPIO_PBCON); _DEBUG_PRINTF("GPIO_PCDR: %02x",(unsigned char)GPIO_PCDR); _DEBUG_PRINTF("GPIO_PCCON: %02x",(unsigned char)GPIO_PCCON); _DEBUG_PRINTF("GPIO_PDDR: %02x",(unsigned char)GPIO_PDDR); _DEBUG_PRINTF("GPIO_PDCON: %02x",(unsigned char)GPIO_PDCON); _DEBUG_PRINTF("ADC0: %d", adc_read(0)); _DEBUG_PRINTF("ADC1: %d", adc_read(1)); _DEBUG_PRINTF("ADC2: %d", adc_read(2)); _DEBUG_PRINTF("ADC3: %d", adc_read(3)); lcd_update(); if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) break; } lcd_setfont(FONT_UI); return false; }
bool dbg_hw_info(void) { int line; lcd_clear_display(); lcd_setfont(FONT_SYSFIXED); while(1) { lcd_clear_display(); line = 0; /* _DEBUG_PRINTF statements can be added here to show debug info */ _DEBUG_PRINTF("SCU_ID: 0x%0x", SCU_ID); _DEBUG_PRINTF("SCU_PLLCON1: 0x%0x", SCU_PLLCON1); _DEBUG_PRINTF("SCU_PLLCON2: 0x%0x", SCU_PLLCON2); _DEBUG_PRINTF("SCU_PLLCON3: 0x%0x", SCU_PLLCON3); _DEBUG_PRINTF("SCU_DIVCON1: 0x%0x", SCU_DIVCON1); _DEBUG_PRINTF("SCU_CLKCFG: 0x%0x", SCU_CLKCFG); _DEBUG_PRINTF("SCU_CHIPCFG: 0x%0x", SCU_CHIPCFG); line++; _DEBUG_PRINTF("sd_debug_time_rd: %d", sd_debug_time_rd); _DEBUG_PRINTF("sd_debug_time_wr: %d", sd_debug_time_wr); for(int i = 0; i < 4; i++) { unsigned long memmap = *(&MEMMAPA + i); unsigned addr = memmap & 0xff000000; unsigned size = memmap & 0xff; const char *size_name; switch(size) { case 0: size = 0; size_name = "invalid"; break; case 0xfe: size = 32 * 1024 * 1024; size_name = "32MB"; break; case 0xfc: size = 64 * 1024 * 1024; size_name = "64MB"; break; case 0xf8: size = 128 * 1024 * 1024; size_name = "128MB"; break; default: size = 0; size_name = "unk"; break; } _DEBUG_PRINTF("Uncached %c: [0x%x,0x%x[ (size=0x%x / %s)", 'A' + i, addr, addr + size, size, size_name); } lcd_update(); switch(button_get_w_tmo(HZ/20)) { case DEBUG_CANCEL: case BUTTON_REL: lcd_setfont(FONT_UI); return false; } } lcd_setfont(FONT_UI); return false; }