#include #include #include #include #include #define LPT 0x378 #define FIFO 1 #define FIFOSIZE 1024 #define LEDPERIOD 200000 * 1000 pthread_t lpt_thread,fifo_thread; volatile int i; char msg[FIFOSIZE]; int fifo_handler(unsigned int fifo){ memset(msg,0,sizeof(msg)); rtf_get(FIFO,msg,sizeof(msg)); rtl_printf("MSG : %s",msg); return 0; } void *fifo_routine(void *arg){ struct sched_param p; p.sched_priority = 2; pthread_setschedparam(pthread_self(),SCHED_FIFO,&p); rtf_create_handler(FIFO,&fifo_handler); return 0; } void *lpt_routine(void *arg) { struct sched_param p; p.sched_priority = 1; pthread_setschedparam(pthread_self(),SCHED_FIFO,&p); pthread_make_periodic_np(pthread_self(),gethrtime(),LEDPERIOD); while (1) { pthread_wait_np(); if((i & 0x01) == 0){ i = 0x01 | inb(LPT); }else{ i = 0xfe & inb(LPT); } outb(i,LPT); } return 0; } int init_module(void) { rtf_create(FIFO,FIFOSIZE); pthread_create(&lpt_thread,NULL,lpt_routine,0); pthread_create(&fifo_thread,NULL,fifo_routine,0); return 0; } void cleanup_module(void) { i = 0xfe & inb(LPT); outb(i,LPT); rtf_destroy(FIFO); pthread_delete_np(lpt_thread); pthread_delete_np(fifo_thread); }