/* close framebuffer*/ static void fb_close(PSD psd) { diag_printf("%s - NOT IMPLEMENTED\n", __FUNCTION__); #if 0 int tty; /* if not opened, return*/ if(status != 2) return; status = 1; /* reset hw palette*/ ioctl_setpalette(0, 256, saved_red, saved_green, saved_blue); /* unmap framebuffer*/ // munmap(psd->addr, psd->size); /* close framebuffer*/ close(fb); #endif }
static void do_swab(int argc, char *argv[]) { // Fill a region of memory with a pattern struct option_info opts[4]; unsigned long base; long len; bool base_set, len_set; bool set_32bit, set_16bit; init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, (void *)&base, (bool *)&base_set, "base address"); init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM, (void *)&len, (bool *)&len_set, "length"); init_opts(&opts[2], '4', false, OPTION_ARG_TYPE_FLG, (void *)&set_32bit, (bool *)0, "fill 32 bit units"); init_opts(&opts[3], '2', false, OPTION_ARG_TYPE_FLG, (void *)&set_16bit, (bool *)0, "fill 16 bit units"); if (!scan_opts(argc, argv, 1, opts, 4, 0, 0, "")) { return; } if (!base_set || !len_set) { diag_printf("usage: swab -b <addr> -l <length> [-2|-4]\n"); return; } if (set_16bit) { // 16 bits at a time while ((len -= sizeof(cyg_uint16)) >= 0) { *(cyg_uint16 *)base = CYG_SWAP16(*(cyg_uint16 *)base); base += sizeof(cyg_uint16); } } else { // Default - 32 bits while ((len -= sizeof(cyg_uint32)) >= 0) { *(cyg_uint32 *)base = CYG_SWAP32(*(cyg_uint32 *)base); base += sizeof(cyg_uint32); } } }
// ------------------------------------------------------------------------ // The management thread function void dhcp_mgt_entry( cyg_addrword_t loop_on_failure ) { int j; while ( 1 ) { while ( 1 ) { cyg_semaphore_wait( &dhcp_needs_attention ); diag_printf("dhcp wakeup01\n"); if ( ! dhcp_bind() ) // a lease expired break; // If we need to re-bind } dhcp_halt(); // tear everything down if ( !loop_on_failure ) return; // exit the thread/return init_all_network_interfaces(); // re-initialize for ( j = 0; j < CYGPKG_NET_NLOOP; j++ ) init_loopback_interface( j ); OnSetIP(); #ifdef CYGPKG_SNMPAGENT SnmpdShutDown(0); // Cycle the snmpd state #endif } }
static void lcd_test(int depth) { int i, j; diag_printf("Set depth %d\n", depth); lcd_on(depth); lcd_clear(); for (j = 0; j < 5; j++) { for (i = 0; i < width; i++) { lcd_putc('A'); } } lcd_putc('\n'); lcd_putc('\n'); cyg_thread_delay(5*100); for (j = 0; j < 5; j++) { for (i = FIRST_CHAR; i <= LAST_CHAR; i++) { lcd_putc(i); } } cyg_thread_delay(5*100); }
/* * ccp_open - CCP is allowed to come up. */ void ccp_open(PPP_IF_VAR_T *pPppIf) { diag_printf("\n<ccp_open>\n"); fsm *f = &pPppIf->ccp_fsm; if (f->state != OPENED) ccp_flags_set(&pPppIf->pSc->sc_flags,1, 0); /* * Find out which compressors the kernel supports before * deciding whether to open in silent mode. */ ccp_resetci(f); if (!ANY_COMPRESS(f->pPppIf->ccp_gotoptions)) f->flags |= OPT_SILENT; { //Added by Eddy int ipmode = 0; CFG_get(CFG_WAN_IP_MODE, &ipmode); if (ipmode == PPPOEMODE) f->flags |= OPT_SILENT; #ifdef CONFIG_PPTP_PPPOE //Added by Haitao int pptp_wanif = 0; CFG_get(CFG_PTP_WANIF, &pptp_wanif); if(ipmode == PPTPMODE && pptp_wanif == 2 && !strcmp(pPppIf->pppname,"ppp0"))//for pptp over pppoe use ppp f->flags |= OPT_SILENT; #endif #ifdef CONFIG_L2TP_OVER_PPPOE int l2tp_wanif = 0; CFG_get(CFG_L2T_WANIF, &l2tp_wanif); if((ipmode == L2TPMODE) && (l2tp_wanif == 2) && (!strcmp(pPppIf->pppname,"ppp0")))//for l2tp over pppoe use ppp f->flags |= OPT_SILENT; #endif } fsm_open(f); }
void battery_test_menu (MENU_ARG arg) { // Test Menu Table static MENU_ITEM batteryMenu[] = { {"Write data to SDRAM", battery_test_write, NULL}, {"Check data from SDRAM", battery_test_read, NULL}, }; unsigned int num_menu_items = (sizeof (batteryMenu) / sizeof (batteryMenu[0])); char *menu_title = "\n Battery Backup SDRAM memory test."; diag_printf ("\n*************************************************************************\n"); diag_printf ("* This test will enable you to perform a battery test in 4 steps: *\n"); diag_printf ("* 1/ Select option 1 to write test pattern, *\n"); diag_printf ("* 2/ Power the board off and wait 60 seconds, *\n"); diag_printf ("* 3/ Power the board back on, *\n"); diag_printf ("* 4/ Select option 2 to read back and compare test pattern *\n"); diag_printf ("*************************************************************************"); menu (batteryMenu, num_menu_items, menu_title, MENU_OPT_NONE); diag_printf ("\n"); }
// Starting from the given directory, find the inode number, filetype, and // parent inode for the file pointed to by the given symbolic link inode. // If successful, fills out ino_info_t and return true. // static int e2fs_follow_symlink(e2fs_desc_t *e2fs, cyg_uint32 dir_ino, cyg_uint32 sym_ino, ino_info_t *info) { #define MAX_SYMLINK_NAME 255 char symlink[MAX_SYMLINK_NAME+1]; int pathlen; cyg_uint32 block_nr; e2fs_inode_t inode; if (!e2fs_get_inode(e2fs, sym_ino, &inode)) { #if DEBUG_E2FS > 0 diag_printf("%s: e2fs_get_inode [%d] failed\n", __FUNCTION__, *ino); #endif return 0; } pathlen = SWAB_LE32(inode.size); if (pathlen > MAX_SYMLINK_NAME) return 0; if (inode.blocks) { if (!e2fs_inode_block(e2fs, &inode, 0, &block_nr)) return 0; if (block_nr) { if (!PARTITION_READ(e2fs->part, E2FS_BLOCK_TO_SECTOR(e2fs, block_nr), blockbuf, e2fs->blocksize/SECTOR_SIZE)) return 0; memcpy(symlink, blockbuf, pathlen); } else return 0; } else { // small enough path to fit in inode struct memcpy(symlink, (char *)&inode.block[0], pathlen); } symlink[pathlen] = 0; return e2fs_inode_lookup(e2fs, dir_ino, symlink, info); }
// Check input line to see if it needs history expansion. If so, // try to find matching command and replace buffer as appropriate. static void expand_history(char *buf) { int ncmds = _cl_max_index + 1; int i, index, len; if (buf[0] != '!' || buf[1] == '\0') return; if (ncmds > 0) { if (!strcmp(buf, "!!")) { strcpy(buf, _cl_lines[_cl_index]); return; } if ((index = parse_history_index(buf + 1)) >= 0) { if (index <= _cl_real_index) { while (index >= _CL_NUM_LINES) { index -= _CL_NUM_LINES; } strcpy(buf, _cl_lines[index]); return; } } else { len = strlen(buf + 1); for (i = 0, index = _cl_index; i < ncmds; i++) { if (!strncmp(_cl_lines[index], buf+1, len)) { strcpy(buf, _cl_lines[index]); return; } if (--index < 0) index = _cl_max_index; } } } diag_printf("%s: event not found\n", buf); *buf = '\0'; }
BOOL MCI_TaskInit(VOID) // MCI_MEDIA_PLAY_REQ, { diag_printf( "*******************MCI_TaskInit**********************"); mmc_MemInit(); //MMC_LcdWidth=MMC_GetLcdWidth(); //MMC_LcdHeight=MMC_GetLcdHeight(); /* HANDLE hTask; hTask = COS_CreateTask((PTASK_ENTRY)MMCTask, NULL, NULL, MMC_TASK_STACK_SIZE, MMC_TASK_PRIORITY, COS_CREATE_DEFAULT, 0, "MMC Task"); //ASSERT(hTask != HNULL); SetMCITaskHandle(MBOX_ID_MMC, hTask); // creat asyn fs task. g_hAsynFsTask = COS_CreateTask(BAL_AsynFsTask, NULL, NULL, ASYNFS_TASK_STACK_SIZE, ASYNFS_TASK_PRIORITY, COS_CREATE_DEFAULT, 0, "ASYNFS Task"); */ /* hTask = COS_CreateTask(MMCTask, NULL, NULL, USB_TASK_STACK_SIZE, USB_TASK_PRIORITY, COS_CREATE_DEFAULT, 0, "USB Task"); ASSERT(hTask != HNULL); SetMCITaskHandle(MBOX_ID_MMC, hTask);*/ return TRUE; }
static cyg_bool _net_io_getc_nonblock(void* __ch_data, cyg_uint8* ch) { if (in_buflen == 0) { __tcp_poll(); if (tcp_sock.state == _CLOSE_WAIT) { // This connection is breaking if (tcp_sock.data_bytes == 0 && tcp_sock.rxcnt == 0) { __tcp_close(&tcp_sock); return false; } } if (tcp_sock.state == _CLOSED) { // The connection is gone net_io_revert_console(); *ch = '\n'; return true; } in_buflen = __tcp_read(&tcp_sock, in_buf, sizeof(in_buf)); in_bufp = in_buf; #ifdef DEBUG_TCP if (show_tcp && (in_buflen > 0)) { int old_console; old_console = start_console(); diag_printf("%s:%d\n", __FUNCTION__, __LINE__); diag_dump_buf(in_buf, in_buflen); end_console(old_console); } #endif // DEBUG_TCP } if (in_buflen) { *ch = *in_bufp++; in_buflen--; return true; } else { return false; } }
void intr_main( void ) { CYG_INTERRUPT_STATE oldints; #if 1 cyg_drv_interrupt_create(CYGNUM_HAL_INTERRUPT_RTC, 1, ISR_DATA, isr, NULL, &intr_handle, &intr); cyg_drv_interrupt_attach(intr_handle); HAL_CLOCK_INITIALIZE( CYGNUM_HAL_RTC_PERIOD ); cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_RTC); HAL_ENABLE_INTERRUPTS(); #endif while(ticks < 500000000 ) { diag_printf("ticks %d\n", ticks); } HAL_DISABLE_INTERRUPTS(oldints); CYG_TEST_PASS_FINISH("HAL interrupt test"); }
static void __udp_recvfrom_handler(udp_socket_t * skt, char *buf, int len, ip_route_t * src_route, word src_port) { if (recvfrom_server == NULL || recvfrom_buf == NULL) return; if (recvfrom_server->sin_port && recvfrom_server->sin_port != htons(src_port)) return; // Move data to waiting buffer recvfrom_len = len; memcpy(recvfrom_buf, buf, len); if (recvfrom_server) { recvfrom_server->sin_port = htons(src_port); memcpy(&recvfrom_server->sin_addr, &src_route->ip_addr, sizeof(src_route->ip_addr)); recvfrom_buf = (char *)0; // Tell reader we got a packet } else { diag_printf("udp_recvfrom - dropped packet of %d bytes\n", len); } }
VOS_UINT32 diag_CreateLogBuf(DIAG_BUF_CTRL_STRU *pstBufCtrl, VOS_INT32 lBufSize) { /* 参数检测 外部保证了不为空*/ pstBufCtrl->lAlloc = 0; pstBufCtrl->lRelease = 0; pstBufCtrl->lPadding = 0; pstBufCtrl->lBufSize = lBufSize; /*申请uncache的动态内存区*/ pstBufCtrl->pucBuf = diag_BuffPhyToVirt(pstBufCtrl->pucRealBuf,(VOS_UINT8*)DIAG_MEM_ADDR_BASE,(VOS_UINT8*)g_DiagMemVirt,(VOS_UINT32)(pstBufCtrl->lBufSize)); /* 分配内存失败 */ if (VOS_NULL_PTR == pstBufCtrl->pucBuf) { g_stDiagToHsoErrRecord.usNoMemErr++; return ERR_MSP_MALLOC_FAILUE; } diag_printf("diag_CreateLogBuf: real addr=%p, virt addr==%p\n", pstBufCtrl->pucRealBuf, pstBufCtrl->pucBuf); return ERR_MSP_SUCCESS; }
void show_help(struct cmd *cmd, struct cmd *cmd_end, char *which, char *pre) { bool show; int len = 0; if (which) { len = strlen(which); } while (cmd != cmd_end) { show = true; if (which && (strncasecmp(which, cmd->str, len) != 0)) { show = false; } if (show) { diag_printf("%s\n %s %s %s\n", cmd->help, pre, cmd->str, cmd->usage); if ((cmd->sub_cmds != (struct cmd *)0) && (which != (char *)0)) { show_help(cmd->sub_cmds, cmd->sub_cmds_end, 0, cmd->str); } } cmd++; } }
// Function to initialize the device. Called at bootstrap time. static bool quicc2pro_serial_init(struct cyg_devtab_entry *tab) { serial_channel *chan = (serial_channel *)tab->priv; quicc2pro_serial_info *quicc2pro_chan = (quicc2pro_serial_info *)chan->dev_priv; #ifdef CYGDBG_IO_INIT diag_printf("QUICC2PRO SERIAL init - dev: %x.%d\n", quicc2pro_chan->base, quicc2pro_chan->int_num); #endif (chan->callbacks->serial_init)(chan); // Really only required for interrupt driven devices if (chan->out_cbuf.len != 0) { cyg_drv_interrupt_create(quicc2pro_chan->int_num, 0, // can change IRQ0 priority (cyg_addrword_t)chan, // Data item passed to interrupt handler quicc2pro_serial_ISR, quicc2pro_serial_DSR, &quicc2pro_chan->serial_interrupt_handle, &quicc2pro_chan->serial_interrupt); cyg_drv_interrupt_attach(quicc2pro_chan->serial_interrupt_handle); cyg_drv_interrupt_unmask(quicc2pro_chan->int_num); } quicc2pro_serial_config_port(chan, &chan->config, true); return true; }
static void time0(register cyg_uint32 stride) { register cyg_uint32 j,k; cyg_tick_count_t count0, count1; cyg_ucount32 t; register char c; count0 = cyg_current_time(); k = 0; if ( cyg_test_is_simulator ) k = 3960; for(; k<4000;k++) { for(j=0; j<(HAL_DCACHE_SIZE/HAL_DCACHE_LINE_SIZE); j++) { c=m[stride*j]; } } count1 = cyg_current_time(); t = count1 - count0; diag_printf("stride=%d, time=%d\n", stride, t); }
static Cyg_ErrNo synth_disk_write(disk_channel *chan, const void *buf, cyg_uint32 len, cyg_uint32 block_num) { synth_disk_info_t *synth_info = (synth_disk_info_t *)chan->dev_priv; #ifdef DEBUG diag_printf("synth disk write block %d\n", block_num); #endif if (synth_info->filefd >= 0) { cyg_hal_sys_lseek(synth_info->filefd, block_num * chan->info->block_size, CYG_HAL_SYS_SEEK_SET); cyg_hal_sys_write(synth_info->filefd, buf, len*512); // cyg_hal_sys_fdatasync(synth_info->filefd); return ENOERR; } return -EIO; }
/** * @brief This function finds the CFP in * region_cfp_table based on region and band parameter. * * @param region The region code * @param band The band * @param cfp_no A pointer to CFP number * @return A pointer to CFP */ CHANNEL_FREQ_POWER * wlan_get_region_cfp_table(cyg_uint8 region, cyg_uint8 band, int *cfp_no) { int i; ENTER(); for (i = 0; i < sizeof(region_cfp_table) / sizeof(region_cfp_table_t); i++) { diag_printf("region_cfp_table[i].region=%d\n", region_cfp_table[i].region); if (region_cfp_table[i].region == region) { { *cfp_no = region_cfp_table[i].cfp_no_BG; LEAVE(); return region_cfp_table[i].cfp_BG; } } } LEAVE(); return NULL; }
/** * @brief This function handles the timeout of packet * transmission * * @param dev A pointer to net_device structure * @return n/a */ static void wlan_tx_timeout(struct net_device *dev) { wlan_private *priv = (wlan_private *) dev->priv; ENTER(); diag_printf("tx watch dog timeout!\n"); priv->wlan_dev.dnld_sent = DNLD_RES_RECEIVED; UpdateTransStart(dev); if (priv->adapter->CurrentTxSkb) { //wake_up_interruptible(&priv->MainThread.waitQ); cyg_flag_setbits( &priv->MainThread.waitQ_flag_q, 1 ); } else { //os_start_queue(priv); } LEAVE(); }
static uint32_t get_numberofentries() { FILE* fd; char line[1024]; int32_t n_entries = 0, i = 0; boolean isfound = FALSE; if ((fd = fopen(DB_FILE_PATH, "r")) == NULL) { diag_printf("[Error] : While opening the file\n", 0, 4, goptionflag, 0, NULL); return 0; } while ( fgets (line, sizeof(line), fd) != NULL ) { n_entries++; } /* Decrement 1 for version and the last line /r/n */ n_entries-= 2; /* check if n_entries is prime number else change to prime number */ while (1) { for (i = 2; i<n_entries; i++) { if ( n_entries % i == 0 ) { /* n_entries is divisible, break for loop */ isfound = TRUE; break; } } if (!isfound && n_entries > 2) break; isfound = FALSE; /* Increment n_entries and check is it prime number */ n_entries++; } fclose(fd); debug_printf( "Number of entries is %d\n", n_entries); return n_entries; }
// Function to initialize the device. Called at bootstrap time. static bool ebsa285_serial_init(struct cyg_devtab_entry *tab) { serial_channel *chan = (serial_channel *)tab->priv; ebsa285_serial_info *ebsa285_chan = (ebsa285_serial_info *)chan->dev_priv; #ifdef CYGDBG_IO_INIT diag_printf("EBSA285 SERIAL init - dev: %x\n", ebsa285_chan); #endif (chan->callbacks->serial_init)(chan); // Really only required for interrupt driven devices if (chan->out_cbuf.len != 0) { // first for rx cyg_drv_interrupt_create(ebsa285_chan->rx.int_num, 99, // Priority - unused (cyg_addrword_t)chan, // Data item passed to interrupt handler ebsa285_serial_rx_ISR, ebsa285_serial_rx_DSR, &ebsa285_chan->rx.serial_interrupt_handle, &ebsa285_chan->rx.serial_interrupt); cyg_drv_interrupt_attach(ebsa285_chan->rx.serial_interrupt_handle); cyg_drv_interrupt_unmask(ebsa285_chan->rx.int_num); // then for tx cyg_drv_interrupt_create(ebsa285_chan->tx.int_num, 99, // Priority - unused (cyg_addrword_t)chan, // Data item passed to interrupt handler ebsa285_serial_tx_ISR, ebsa285_serial_tx_DSR, &ebsa285_chan->tx.serial_interrupt_handle, &ebsa285_chan->tx.serial_interrupt); cyg_drv_interrupt_attach(ebsa285_chan->tx.serial_interrupt_handle); // DO NOT cyg_drv_interrupt_unmask(ebsa285_chan->tx.int_num); ebsa285_chan->tx_active = 0; } (void)ebsa285_serial_config_port(chan, &chan->config, true); return true; }
BOOL SetWlanHostSleepCfg(const char *pcInterface, int nGPIO) { int rt; int fd; unsigned long ipaddr; struct iwreq wrq; char buf[32]; int ret = WLAN_STATUS_SUCCESS; memset(buf, 0, sizeof(buf)); if (pcInterface == NULL) { fprintf(stderr, "illegal call function SetWlanChannel!\n"); return FALSE; } ipaddr = GetIPAddress(pcInterface); if ((fd = socket(AF_INET,SOCK_DGRAM,0)) < 0) return FALSE; memset(&wrq, 0, sizeof(wrq)); strcpy(wrq.ifr_name, pcInterface); /* broadcast=1 ; unicast=2 ; multicast=3 */ sprintf(buf, "03 %02x 0xa0 %08x", nGPIO, ipaddr);//set criteria/gpio/gap // sprintf(buf, "02 %02x 0xa0", nGPIO);//set criteria/gpio/gap wrq.u.data.pointer = buf; wrq.u.essid.length = strlen(buf) + 1; rt = ioctl(fd, WLANHOSTSLEEPCFG, &wrq); close(fd); if(rt >= 0) diag_printf("set host sleep config success %s\n", buf); return (rt >= 0 ? TRUE : FALSE); }
int function(int n, ...) { va_list args; int c = 11 * n; int i = 1; int res = 1; CYG_ASSERT(n >= 0 && n < 8, "Invalid count argument"); va_start(args, n); for (i = 1; i <= n; c++, i++) { int v = va_arg(args, int); if (v != c) { diag_printf("FAIL:<Bad argument: index %d expected %d got %d>\n", i, c, v); res = 0; } } va_end(args); return res; }
void write_sector(int num, char *buf) { int i, cnt; volatile char *wrt = (volatile char *)&FLASH[num*sector_size]; // diag_printf("Writing to %08x\n", wrt); // Enter Program Mode FLASH[SEQ_ADD1] = START_CMD1; FLASH[SEQ_ADD2] = START_CMD2; FLASH[SEQ_ADD1] = PROG_CMD; // Note: write bytes as longs regardless of bus width for (i = 0; i < sector_size; i++) { wrt[i] = BUF(i); } // Wait for sector to program cnt = 0; i = sector_size - 1; while (wrt[i] != BUF(i)) { if (cnt++ > 0x01000000) break; } // diag_printf("Out - i: %d, wrt[i] = %08X.%08X, BUF(i) = %08X, count = %x\n", i, &wrt[i], wrt[i], BUF(i), cnt); // Verify for (i = 0; i < sector_size; i++) { for (cnt = 0; cnt < 10; cnt++) { if (wrt[i] == BUF(i)) break; cyg_thread_delay(1); } if (cnt == 10) { diag_printf("Can't program at 0x%08X: %02X not %02X\n", wrt, *wrt, BUF(0)); } } }
// Internal function to actually configure the hardware to desired baud rate, etc. static bool edb7xxx_serial_config_port(serial_channel *chan, cyg_serial_info_t *new_config, bool init) { edb7xxx_serial_info *edb7xxx_chan = (edb7xxx_serial_info *)chan->dev_priv; volatile cyg_uint32 *syscon = (volatile cyg_uint32 *)edb7xxx_chan->syscon; volatile cyg_uint32 *blcfg = (volatile cyg_uint32 *)edb7xxx_chan->control; unsigned int baud_divisor = select_baud[new_config->baud]; cyg_uint32 _lcr; if (baud_divisor == 0) return false; // Disable port interrupts while changing hardware _lcr = select_word_length[new_config->word_length - CYGNUM_SERIAL_WORD_LENGTH_5] | select_stop_bits[new_config->stop] | select_parity[new_config->parity] | UBLCR_FIFOEN | UART_BITRATE(baud_divisor); #ifdef CYGDBG_IO_INIT diag_printf("Set CTL: %x = %x\n", blcfg, _lcr); #endif *blcfg = _lcr; *syscon |= SYSCON1_UART1EN; if (new_config != &chan->config) { chan->config = *new_config; } return true; }
/** prints histogram to screen @param histo: histogram, which should be printed */ void print_histogram (histogram * histo){ int i,j; printf("\n-------------------------------------------------------------------------------------------------\n"); for (i=0;i<NS;i++){ diag_printf("| "); for (j=0; j<NH; j++){ printf("%d\t| ", histo->histo[i*NS+j]); } printf("|||\t %d \t|", histo->histo[(NH*NS)+i]); printf("\n-------------------------------------------------------------------------------------------------\n"); } printf("\n"); }
void callout_stop(struct callout *c) { int spl = cyg_splinternal(); #ifdef TIMEOUT_DEBUG diag_printf("%s(%p) = %x\n", __FUNCTION__, c, c->flags); #endif if ((c->flags & CALLOUT_PENDING) == 0) { c->flags &= ~CALLOUT_ACTIVE; cyg_splx(spl); return; } c->flags &= ~(CALLOUT_PENDING | CALLOUT_ACTIVE); if (c->next) { c->next->prev = c->prev; } if (c->prev) { c->prev->next = c->next; } else { timeouts = c->next; } cyg_splx(spl); }
// Get a group descriptor. Returns non-zero for success. // static int e2fs_get_gdesc(e2fs_desc_t *e2fs, cyg_uint32 group_nr, e2fs_group_t *gdesc) { cyg_uint32 sec_nr; if (group_nr < e2fs->gdesc_first || group_nr >= (e2fs->gdesc_first + E2FS_GDESC_CACHE_SIZE)) { // cache miss sec_nr = E2FS_BLOCK_TO_SECTOR(e2fs, e2fs->gdesc_block); sec_nr += (group_nr / E2FS_GDESC_PER_SECTOR); #if DEBUG_E2FS > 2 diag_printf("%s: group[%d] cache miss, sec_nr[%d]\n", __FUNCTION__, group_nr, sec_nr); #endif if (!PARTITION_READ(e2fs->part, sec_nr, (cyg_uint32 *)e2fs->gdesc_cache, sizeof(e2fs->gdesc_cache)/SECTOR_SIZE)) return 0; } *gdesc = e2fs->gdesc_cache[group_nr - e2fs->gdesc_first]; return 1; }
static void net_io_init(void) { static int init = 0; if (!init) { hal_virtual_comm_table_t* comm; int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); // Setup procs in the vector table CYGACC_CALL_IF_SET_CONSOLE_COMM(TCP_CHANNEL); comm = CYGACC_CALL_IF_CONSOLE_PROCS(); //CYGACC_COMM_IF_CH_DATA_SET(*comm, chan); CYGACC_COMM_IF_WRITE_SET(*comm, net_io_write); CYGACC_COMM_IF_READ_SET(*comm, net_io_read); CYGACC_COMM_IF_PUTC_SET(*comm, net_io_putc); CYGACC_COMM_IF_GETC_SET(*comm, net_io_getc); CYGACC_COMM_IF_CONTROL_SET(*comm, net_io_control); CYGACC_COMM_IF_DBG_ISR_SET(*comm, net_io_isr); CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, net_io_getc_timeout); // Disable interrupts via this interface to set static // state into correct state. net_io_control( comm, __COMMCTL_IRQ_DISABLE ); // Restore original console CYGACC_CALL_IF_SET_CONSOLE_COMM(cur); init = 1; gdb_active = false; } __tcp_listen(&tcp_sock, gdb_port); state = tcp_sock.state; #ifdef DEBUG_TCP diag_printf("show tcp = %p\n", (void *)&show_tcp); #endif }
int main( int argc, char **argv ) { int err, iteration; struct mallinfo minfo ; CYG_TEST_INIT(); // -------------------------------------------------------------- CYG_TEST_INFO("mount /"); err = mount( CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1, "/", "jffs2" ); if( err < 0 ) SHOW_RESULT( mount, err ); chdir ("/"); iteration=0; create_file(iteration); while (iteration < ITERATIONS) { if (!(iteration % 1000)) { minfo = mallinfo(); diag_printf("<INFO> Iteration %07d fordblks = %7d\n", iteration, minfo.fordblks); } iteration++; create_file(iteration); check_file(iteration-1); delete_file(iteration-1); check_file(iteration); } CYG_TEST_INFO("umount /"); err = umount( "/" ); if( err < 0 ) SHOW_RESULT( umount, err ); CYG_TEST_PASS_FINISH("jffs2_3"); }