FUNCTION Msgh *output_buf () { register Msgh *m; register int count = 0; Debug /* first try to allocate space */ m = (Msgh *) l_create (msgdefsize); if (m == NULLMSGH) { /* no space--get desperate */ while (BITTST (report_buf->flags, LOCKED)) { if (count++ == 10000) { /* Wait for the MI to free the buffer.. */ dprintf ("Waiting for report buffer to be unlocked...\n"); count = 0; } } m = report_buf; /* grab report_buf */ } clear ( m, sizeof (Msgh) ); /* clear it */ if ( m == report_buf ) BITSET (m->flags, LOCKED); /* Tell rest of system not to use */ return m; }
FUNCTION Msgh *sysbuf () { register Msgh *m; register int count = 0; Debug /* first try to allocate space */ m = (Msgh *) l_create (msgdefsize); if (m == NULLMSGH) { /* no space--get desperate */ while (BITTST (emergbuf->flags, LOCKED)) { if (count++ == 10000) { /* Wait for the MI to free the buffer.. */ _pprintf ("Waiting for emergbuf to be unlocked... %x\n", emergbuf); send_e_from_q(); /* clear emergbuf */ count = 0; } } m = emergbuf; /* grab emergbuf */ } clear ( m, sizeof (Msgh) ); /* clear it */ if ( m == emergbuf ) BITSET (m->flags, LOCKED); /* Tell rest of system not to use */ return m; }
void start_timer(unsigned r0, unsigned r1, unsigned r2, unsigned r3) { int val; int i; #define BIT(n) (1<<n) #define BITTST(val, n) ((val) & BIT(n)) #define TST(val, b) ((val) & (b)) hw_timer_rotary[0] = (void *)(0x80068000); /* have ROTCTRL */ hw_timer_rotary[1] = (void *)(0x80068050); hw_timer_rotary[2] = (void *)(0x80068080); hw_timer_rotary[3] = (void *)(0x800680C0); val = hw_timer_rotary[0]->HW_TIMROT_ROTCTRL[0]; printk("This SoC has:\n"); if(BITTST(val,25)) printk("timer 0\n"); if(BITTST(val,26)) printk("timer 1\n"); if(BITTST(val,27)) printk("timer 2\n"); if(BITTST(val,28)) printk("timer 3\n"); #define IRQ (1<<15) #define IRQ_EN (1<<14) #define MATCH_MODE (1<<11) #define POLARITY (1<<8) #define UPDATE (1<<7) #define RELOAD (1<<6) #define PRESCALE(n) ((n)<<4) #define DIV_BY_8 (0x3) #define SELECT(n) ((n)<<0) #define TICK_ALWAYS (0XF) #define SET 1 #define CLR 2 #define TOG 3 hw_timer_rotary[1]->HW_TIMROT_FIXED_COUNT[0] = 0x00011000; val = IRQ_EN | UPDATE | RELOAD | PRESCALE(TICK_ALWAYS) | SELECT(0xB); out_w(HW_TIMROT_TIMCTRL1, val); while(1){ static int random = 0; random++; printk("[%04d]wait timer1 irq\n", random); waitMsec(100); val = hw_timer_rotary[1]->HW_TIMROT_TIMCTRL[0]; printk("%016b\n", val); val = in_w(HW_TIMROT_RUNNING_COUNT1); printk("timer running @[0x%x]\n", val); val = in_w(HW_TIMROT_VERSION); printk("timer version @[%X]\n", val); if(random>300) break; } printk("Goodbye TIMER!\n"); }