//////////////////////////////////////////////////////////////////////////////// // print_words // PURPOSE: Prints the values of size words. // PARAMS: (IN) u8 *start - starting address. // (IN) int size - number of words to print. // RETURNS: Nothing. //////////////////////////////////////////////////////////////////////////////// void print_words(u16 const *start, int size) { int x = 1; while(size > 0) { char buf[5]; u16toa(*start++, buf); itc_printf(buf); size--; if(!(x++ % 16)) { if(size > 0) { itc_printf("\r\n"); x = 1; } } else { itc_printf(" "); } } itc_printf("\r\n"); }
//////////////////////////////////////////////////////////////////////////////// // print_dwords // PURPOSE: Prints the values of size dwords. // PARAMS: (IN) u8 *start - starting address. // (IN) int size - number of dwords to print. // RETURNS: Nothing. //////////////////////////////////////////////////////////////////////////////// void print_dwords(u32 const *start, int size) { int x = 1; while(size > 0) { itc_printf("%x", *start++); size--; if(!(x++ % 8)) { if(size > 0) { itc_printf("\r\n"); x = 1; } } else { itc_printf(" "); } } itc_printf("\r\n"); }
//////////////////////////////////////////////////////////////////////////////// // print_bytes // PURPOSE: Prints the values of size bytes. // PARAMS: (IN) u8 *start - starting address. // (IN) int size - number of bytes to print. // RETURNS: Nothing. //////////////////////////////////////////////////////////////////////////////// void print_bytes(u8 const *start, int size) { int x = 1; while(size > 0) { itc_printf("%b", *start++); size--; if(!(x++ % 27)) { if(size > 0) { itc_printf("\r\n"); x = 1; } } else { itc_printf(" "); } } itc_printf("\r\n"); }
//////////////////////////////////////////////////////////////////////////////// // init_bootp // PURPOSE: Sends a bootp requests, and listens for response. // PARAMS: (IN) u32 *ciaddr - Client IP address returned. // (IN) u32 *siaddr - TFTP or other server address. // (IN) u32 *giaddr - gateway address. // (IN) u32 *smask - IP netmask // RETURNS: 1 for success, 0 for failure. //////////////////////////////////////////////////////////////////////////////// int init_bootp(u32 *ciaddr, u32 *siaddr, u32 *giaddr, u32 *smask) { u8 bootpacket[BOOTP_PACKET_SIZE + UDPIP_HEADER_SIZE]; int gotreply; int i = MAX_RETRIES; u32 stamp = rand(); // Delay a short random amount to space out BOOTP requests from many clients // booting up at once. udelay(rand() % 100000); udelay(rand() % 100000); fillbootp(bootpacket + UDPIP_HEADER_SIZE, status.macaddr, stamp); flush_ethernet (); do { // Transmit BOOTP request udppacket((u16 *)bootpacket, BOOTP_PACKET_SIZE, IP_BROADCAST, 0, //we don't know what our IP address is yet BOOTP_TX_PORT, BOOTP_RX_PORT, status.macaddr); gotreply = listenbootp(stamp, ciaddr, siaddr, giaddr, smask, (char *)&(status.bootfile)); if (!gotreply) { itc_printf("."); } } while(!gotreply && i-- > 0); rx_ethernet_off (); flush_ethernet (); if(i <= 0) { itc_printf("\r\n"); error_print(BOOTP_TIMEOUT_ERROR); return 0; } return 1; }