int init_config(void) { int id, ret, len = 0; void * cfg = (void *)ITEMS_LOWBASE; printf("cfg: 0x%p\n", cfg); id = boot_device(); switch(id) { case DEV_EEPROM: case DEV_FLASH: cfg = (void *)(IRAM_BASE_PA + BL_SIZE_FIXED - ITEM_SIZE_EMBEDDED); len = ITEM_SIZE_EMBEDDED; break ; case DEV_BND: id = DEV_NAND; default: printf("read items: id=%d\n", id); ret = vs_assign_by_id(id, 1); if (ret) return ret; ret = vs_read(cfg, BL_LOC_CONFIG, ITEM_SIZE_NORMAL, 0); if (ret < 0) return ret; len = ITEM_SIZE_NORMAL; } printf("begin init.\n"); return item_init(cfg, len); }
int spi_init_pads(void) { int xom = get_xom(1), index; if(boot_device() != DEV_FLASH) printf("warning: not spi boot\n"); index = (xom == 4) ? 74: ((xom == 6)? 27: 121); pads_chmod(PADSRANGE(index, (index + 3)), PADS_MODE_CTRL, 0); if(ecfg_check_flag(ECFG_ENABLE_PULL_SPI)) { pads_pull(PADSRANGE(index, (index + 3)), 1, 1); pads_pull(index + 2, 1, 0); /* clk */ } return 0; }
void find_inf(void) { long ret; char path[128], *home = getenv("HOME"); if (home) { char myhome[128]; if (!strlen(home)) goto _nohome; strcpy(myhome,home); if (myhome[strlen(myhome)-1] != '\\') strcat(myhome,"\\"); strcpy(path,myhome); strcat(path,"defaults\\"); strcat(path,FILEINF); #ifdef DEBUG printf("%s (?)\n",path); #endif ret = Fopen(path,FO_READ); if (ret >= 0L) read_inf((int)ret); else { strcpy(path,myhome); strcat(path,FILEINF); #ifdef DEBUG printf("%s (?)\n",path); #endif ret = Fopen(path,FO_READ); if (ret < 0L) goto _nohome; read_inf((int)ret); } } else { _nohome: boot_device(path); strcat(path,FILEINF); #ifdef DEBUG printf("%s (?)\n",path); #endif ret = Fopen(path,FO_READ); if (ret >= 0L) read_inf((int)ret); else { strcpy(path,FILEINF); #ifdef DEBUG printf("%s (?)\n",path); #endif ret = Fopen(path,FO_READ); if (ret >= 0L) read_inf((int)ret); else { form_alert(1,MESSAGE_INFNOTFOUND); } } } #ifdef DEBUG printf("\n"); #endif }