/* * Standalone test of SD card driver. * Broken since rdisk implemented. */ #include "param.h" #include "conf.h" #include "systm.h" #include "buf.h" #include "reboot.h" #define SECTSIZE 512 /* size of SD card sector */ size_t physmem; /* total amount of physical memory */ u_int swapstart, nswap; /* start and size of swap space */ //const struct linesw linesw[] = { { 0 } }; int nldisp = 1; char data [SECTSIZE * 2]; extern int card_size (int unit, unsigned *nsectors); extern int card_read (int unit, unsigned offset, char *data, unsigned bcount); extern int card_write (int unit, unsigned offset, char *data, unsigned bcount); extern void sd_preinit(int unit); extern void usbintr (int chan); static void fill_sector (p, byte0, byte1) char *p; unsigned byte0, byte1; { unsigned i; for (i=0; i> 2 & 31); switch (cause & CA_EXC_CODE) { case CA_AdEL: case CA_AdES: printf ("*** badvaddr = 0x%08x\n", mips_read_c0_register (C0_BADVADDR, 0)); } printf (" t0 = %8x s0 = %8x t8 = %8x lo = %8x\n", frame [FRAME_R8], frame [FRAME_R16], frame [FRAME_R24], frame [FRAME_LO]); printf ("at = %8x t1 = %8x s1 = %8x t9 = %8x hi = %8x\n", frame [FRAME_R1], frame [FRAME_R9], frame [FRAME_R17], frame [FRAME_R25], frame [FRAME_HI]); printf ("v0 = %8x t2 = %8x s2 = %8x status = %8x\n", frame [FRAME_R2], frame [FRAME_R10], frame [FRAME_R18], frame [FRAME_STATUS]); printf ("v1 = %8x t3 = %8x s3 = %8x cause = %8x\n", frame [FRAME_R3], frame [FRAME_R11], frame [FRAME_R19], cause); printf ("a0 = %8x t4 = %8x s4 = %8x gp = %8x epc = %8x\n", frame [FRAME_R4], frame [FRAME_R12], frame [FRAME_R20], frame [FRAME_GP], frame [FRAME_PC]); printf ("a1 = %8x t5 = %8x s5 = %8x sp = %8x\n", frame [FRAME_R5], frame [FRAME_R13], frame [FRAME_R21], frame [FRAME_SP]); printf ("a2 = %8x t6 = %8x s6 = %8x fp = %8x\n", frame [FRAME_R6], frame [FRAME_R14], frame [FRAME_R22], frame [FRAME_FP]); printf ("a3 = %8x t7 = %8x s7 = %8x ra = %8x\n", frame [FRAME_R7], frame [FRAME_R15], frame [FRAME_R23], frame [FRAME_RA]); } void exception (frame) /* exception.c */ int *frame; { unsigned c, irq, cause; led_control (LED_KERNEL, 1); cause = mips_read_c0_register (C0_CAUSE, 0); if ((cause & CA_EXC_CODE) != CA_Int) { /* Exception. */ dumpregs (frame); panic ("unexpected exception"); } /* * Hardware interrupt. */ /* Get the current irq number */ c = INTSTAT; if ((c & PIC32_INTSTAT_SRIPL_MASK) == 0) { printf ("*** unexpected interrupt: INTSTAT %08x\n", c); goto ret; } irq = PIC32_INTSTAT_VEC (c); /* Handle the interrupt. */ switch (irq) { case PIC32_VECT_CT: /* Core Timer */ #if 0 /* Increment COMPARE register. */ c = mips_read_c0_register (C0_COMPARE, 0); do { c += (CPU_KHZ * 1000 / HZ + 1) / 2; mips_write_c0_register (C0_COMPARE, 0, c); } while ((int) (c - mips_read_c0_register (C0_COUNT, 0)) < 0); IFSCLR(0) = 1 << PIC32_IRQ_CT; int status = frame [FRAME_STATUS]; hardclock ((caddr_t) frame [FRAME_PC], status); #endif #ifdef CONSOLE_USB /* Poll USB on every timer tick. */ usbintr (0); #endif break; #if defined(CONSOLE_UART1) || defined(CONSOLE_UART2) || \ defined(CONSOLE_UART3) || defined(CONSOLE_UART4) || \ defined(CONSOLE_UART5) || defined(CONSOLE_UART6) #if CONSOLE_UART1 case PIC32_VECT_U1: /* UART1 */ #endif #if CONSOLE_UART2 case PIC32_VECT_U2: /* UART2 */ #endif #if CONSOLE_UART3 case PIC32_VECT_U3: /* UART3 */ #endif #if CONSOLE_UART4 case PIC32_VECT_U4: /* UART4 */ #endif #if CONSOLE_UART5 case PIC32_VECT_U5: /* UART5 */ #endif #if CONSOLE_UART6 case PIC32_VECT_U6: /* UART6 */ #endif uartintr(makedev(UART_MAJOR,0)); break; #endif #ifdef CONSOLE_USB case PIC32_VECT_USB: /* USB */ IFSCLR(1) = 1 << (PIC32_IRQ_USB - 32); usbintr (0); break; #endif default: /* Disable the irq, to avoid loops */ printf ("*** irq %u\n", irq); if (irq < PIC32_VECT_CN) { IECCLR(0) = mask_by_vector [irq]; IFSCLR(0) = mask_by_vector [irq]; } else { IECCLR(1) = mask_by_vector [irq]; IFSCLR(1) = mask_by_vector [irq]; } break; } ret: led_control (LED_KERNEL, 0); } void biodone(bp) register struct buf *bp; { bp->b_flags |= B_DONE; } /* * Stubs. */ int noproc; /* kern_clock.c */ struct fs * getfs(dev) /* ufs_subr.c */ dev_t dev; { return 0; } void sync() /* ufs_subr.c */ { /* empty */ } void ttyowake(tp) /* tty.c */ struct tty *tp; { /* empty */ } void ttychars(tp) /* tty.c */ struct tty *tp; { /* empty */ } void ttyclose(tp) /* tty.c */ struct tty *tp; { /* empty */ } int ttyselect (tp, rw) /* tty.c */ struct tty *tp; int rw; { return 0; } int ttioctl(tp, com, data, flag) /* tty.c */ struct tty *tp; u_int com; caddr_t data; int flag; { return 0; } int ttyoutput(c, tp) /* tty.c */ int c; struct tty *tp; { return 0; } void ttstart(tp) /* tty.c */ struct tty *tp; { /* empty */ } int ttycheckoutq (tp, wait) /* tty.c */ struct tty *tp; int wait; { return 0; } int logwrt (buf, len, log) /* subr_log.c */ char *buf; int len; int log; { return 0; } void logwakeup(unit) /* subr_log.c */ int unit; { /* empty */ } int logisopen(unit) /* subr_log.c */ int unit; { return 0; } int getc(p) /* tty_subr.c */ struct clist *p; { return '*'; }