static void i8250disable(Uart* uart) { Ctlr *ctlr; /* * Turn off DTR and RTS, disable interrupts and fifos. */ (*uart->phys->dtr)(uart, 0); (*uart->phys->rts)(uart, 0); (*uart->phys->fifo)(uart, 0); ctlr = uart->regs; ctlr->sticky[Ier] = 0; csr8w(ctlr, Ier, 0); if(ctlr->iena != 0){ if(irqdisable(ctlr->irq, i8250interrupt, uart, uart->name) == 0) ctlr->iena = 0; } }
static inline void dispatch_syscall(uint32_t *regs) { uint32_t cmd = regs[REG_A0]; FAR _TCB *rtcb = sched_self(); uintptr_t ret = (uintptr_t)ERROR; /* Verify the the SYS call number is within range */ if (cmd < SYS_maxsyscall) { /* Report error and return ERROR */ slldbg("ERROR: Bad SYS call: %d\n", cmd); } else { /* The index into the syscall table is offset by the number of * architecture-specific reserved entries at the beginning of the * SYS call number space. */ int index = cmd - CONFIG_SYS_RESERVED; /* Enable interrupts while the SYSCALL executes */ #ifdef SYSCALL_INTERRUPTIBLE irqenable(); #endif /* Call the correct stub for each SYS call, based on the number of * parameters: $5=parm1, $6=parm2, $7=parm3, $8=parm4, $9=parm5, and * $10=parm6. */ swidbg("Calling stub%d at %p\n", index, g_stubloopkup[index].stub0); switch (g_stubnparms[index]) { /* No parameters */ case 0: ret = g_stublookup[index].stub0(); break; /* Number of parameters: 1 */ case 1: ret = g_stublookup[index].stub1(regs[REG_A1]); break; /* Number of parameters: 2 */ case 2: ret = g_stublookup[index].stub2(regs[REG_A1], regs[REG_A2]); break; /* Number of parameters: 3 */ case 3: ret = g_stublookup[index].stub3(regs[REG_A1], regs[REG_A2], regs[REG_A3]); break; /* Number of parameters: 4 */ case 4: ret = g_stublookup[index].stub4(regs[REG_A1], regs[REG_A2], regs[REG_A3], regs[REG_T0]); break; /* Number of parameters: 5 */ case 5: ret = g_stublookup[index].stub5(regs[REG_A1], regs[REG_A2], regs[REG_A3], regs[REG_T0], regs[REG_T1]); break; /* Number of parameters: 6 */ case 6: ret = g_stublookup[index].stub6(regs[REG_A1], regs[REG_A2], regs[REG_A3], regs[REG_T0], regs[REG_T1], regs[REG_T2]); break; /* Unsupported number of paramters. Report error and return ERROR */ default: slldbg("ERROR: Bad SYS call %d number parameters %d\n", cmd, g_stubnparms[index]); break; } #ifdef SYSCALL_INTERRUPTIBLE irqdisable(); #endif } /* Set up the return vaue. First, check if a context switch occurred. * In this case, regs will no longer be the same as current_regs. In * the case of a context switch, we will have to save the return value * in the TCB where it can be returned later when the task is restarted. */ if (regs != current_regs) { regs = rtcb->xcp.regs; } /* Then return the result in v0 */ swidbg("Return value regs: %p value: %d\n", regs, ret); regs[REG_v0] = (uint32_t)ret; }
void spin_lock_irq(volatile spinlock_t *lock) { irqdisable(); spin_lock(lock); }