static int ui_cmd_showtime(ui_cmdline_t *cmd,int argc,char *argv[]) { uint8_t hr,min,sec; uint8_t mo,day,yr,y2k; int res=0; int fd; uint8_t buf[12]; fd = cfe_open("clock0"); if (fd < 0) { ui_showerror(fd,"could not open clock device"); return fd; } res = cfe_read(fd,buf,8); if (res < 0) { ui_showerror(res,"could not get time/date"); } cfe_close(fd); hr = buf[0]; min = buf[1]; sec = buf[2]; mo = buf[3]; day = buf[4]; yr = buf[5]; y2k = buf[6]; printf("Current date & time is: "); printf("%02X/%02X/%02X%02X %02X:%02X:%02X\n",mo,day,y2k,yr,hr,min,sec); return 0; }
static int cfe_cngetc(struct consdev *cp) { unsigned char ch; if (cfe_read(conhandle, &ch, 1) == 1) { #if defined(KDB) kdb_alt_break(ch, &alt_break_state); #endif return (ch); } return (-1); }
char inbyte (void) { unsigned char c; int rv; while (cfe_read (cfe_conshandle, &c, 1) != 1) ; if (c == '\r') c = '\n'; if (__cfe_echo_input) outbyte (c); return c; }
int cfenet_get(struct iodesc *desc, void *pkt, size_t len, saseconds_t timeout) { satime_t t; int cc; t = getsecs(); cc = 0; while (((getsecs() - t) < timeout) && !cc) { cc = cfe_read(booted_dev_fd,pkt,len); if (cc < 0) break; break; } return cc; }
static struct nvram_header * BCMINITFN(find_devinfo_nvram)(si_t *sih) { int cfe_fd, ret; if (devinfo_nvram_header != NULL) { return (devinfo_nvram_header); } if ((cfe_fd = cfe_open(devinfo_flashdrv_nvram)) < 0) { return NULL; } ret = cfe_read(cfe_fd, (unsigned char *)devinfo_nvram_nvh, NVRAM_SPACE); if (ret >= 0) { devinfo_nvram_header = (struct nvram_header *) devinfo_nvram_nvh; } cfe_close(cfe_fd); return (devinfo_nvram_header); }
int console_read(unsigned char *buffer,int length) { if (console_handle == -1) return -1; return cfe_read(console_handle,buffer,length); }