// Initialize hardware devices void device_hardware_setup(void) { usb_setup(); ps2port_setup(); lpt_setup(); serial_setup(); floppy_setup(); ata_setup(); ahci_setup(); sd_setup(); cbfs_payload_setup(); ramdisk_setup(); virtio_blk_setup(); virtio_scsi_setup(); lsi_scsi_setup(); esp_scsi_setup(); megasas_setup(); pvscsi_setup(); }
int main(void) { static int cog; static char tbuf[_TOKEN_BUFFER]; char c; /************************ initializations ****************************/ sleep(1); //wait for the serial terminal to start /* display system info on serial terminal */ printf("\n*** Pcon %i.%i ***\n\n",_major_version,_minor_version); #if _DRIVEN == _DIOB printf("system is configured to drive a Parallax Digital IO Board\n"); #else printf("system is configured to drive 5 IO pins\n"); #endif /* build file set prefix */ strcat(file_set_prefix,_F_PREFIX); strcat(file_set_prefix,_FILE_SET_ID); printf("file set prefix <%s>\n",file_set_prefix); /* check out the SD card */ if(sd_setup()) { printf("**** sd_setup aborted application ****\n"); return 1; } /* start monitoring the real time clock DS3231 */ rtc_cb.rtc.tdb_lock = locknew(); lockclr(rtc_cb.rtc.tdb_lock); cog = start_rtc(&rtc_cb.rtc); if(cog == -1) { printf("** error attempting to start rtc cog\n cognew returned %i\n\n",cog); return 1; } printf(" DS3231 monitored by code running on cog %i\n",cog); /* setup the dio control block */ dio_cb.dio.tdb_lock = rtc_cb.rtc.tdb_lock; dio_cb.dio.cca_lock = locknew(); lockclr(dio_cb.dio.cca_lock); dio_cb.dio.sch_lock = locknew(); lockclr(dio_cb.dio.sch_lock); dio_cb.dio.update_ptr = &(rtc_cb.rtc.update); dio_cb.dio.td_ptr = &(rtc_cb.rtc.td_buffer); *dio_cb.dio.update_ptr = 0; dio_cb.dio.sch_ptr = bbb; /* start the dio cog */ cog = start_dio(&dio_cb.dio); if(cog == -1) { printf("** error attempting to start dio cog\n cognew returned %i\n\n",cog); return 1; } #if _DRIVEN == _DIOB printf(" DIO Board controlled by code running on cog %i\n",cog); #else printf(" relays controlled by code running on cog %i\n",cog); #endif /* set up unbuffered nonblocking io */ setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); stdin->_flag &= ~_IOCOOKED; stdin->_flag |= _IONONBLOCK; /* initialize fsm(s) parameters */ input_buffer_ptr = input_buffer;//setup so actions routines can mess the buffer cmd_state = 0; //set initial command parser state char_state = 0; //set initial caracter parser state // hold_day = -1; //force schedule load first time through the main loop *input_buffer = ' '; //load a a blank into the buffer to force first prompt process_buffer(); printf("initialization complete\n"); /************************************************************/ /********************** main processing loop ****************/ /************************************************************/ while(1) { /* check for problems */ if(ckeck_abort()) return 1; /* check the token stack */ while(pop_cmd_q(tbuf)) { cmd_fsm(tbuf,&cmd_state); //cycle cmd fsm until queue is empty } /* grab a character from the keyboard if one is present */ c = fgetc(stdin); //nonblocking read /* process input char */ if(c!=_NO_CHAR) { fputc(c, stdout); // echo char if(c==_CR) fputc(_CR, stdout); //second CR after uer input char_fsm(char_type(c),&char_state,&c); //cycle fsm } }; printf("\nnormal termination\n\n"); return 0; }