From: Erik M. <er...@us...> - 2002-02-08 12:55:19
|
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv24965/src/blob Modified Files: reboot.c main.c linux.c Log Message: Change a lot of code to printf() instead of SerialOutput*(). Index: reboot.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/reboot.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- reboot.c 6 Jan 2002 15:46:17 -0000 1.7 +++ reboot.c 8 Feb 2002 12:55:16 -0000 1.8 @@ -33,7 +33,6 @@ #include <blob/error.h> #include <blob/init.h> #include <blob/main.h> -#include <blob/serial.h> @@ -45,11 +44,11 @@ /* sanity check */ if(blob_status.blobType == fromFlash) { printerrprefix(); - SerialOutputString("blob not downloaded\n"); + printf("blob not downloaded\n"); return -EINVAL; } - SerialOutputString("Restarting blob from RAM...\n\n"); + printf("Restarting blob from RAM...\n\n"); serial_flush_output(); Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/main.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- main.c 5 Feb 2002 14:47:54 -0000 1.30 +++ main.c 8 Feb 2002 12:55:16 -0000 1.31 @@ -110,16 +110,14 @@ #endif /* Print the required GPL string */ - SerialOutputString("\nConsider yourself LARTed!\n\n"); - SerialOutputString(version_str); - SerialOutputString("Copyright (C) 1999 2000 2001 " - "Jan-Derk Bakker and Erik Mouw\n"); - SerialOutputString(PACKAGE " comes with ABSOLUTELY NO WARRANTY; " - "read the GNU GPL for details.\n"); - SerialOutputString("This is free software, and you are welcome " - "to redistribute it\n"); - SerialOutputString("under certain conditions; " - "read the GNU GPL for details.\n"); + printf("\nConsider yourself LARTed!\n\n"); + printf("%sCopyright (C) 1999 2000 2001 2002 " + "Jan-Derk Bakker and Erik Mouw\n", version_str); + printf(PACKAGE " comes with ABSOLUTELY NO WARRANTY; " + "read the GNU GPL for details.\n"); + printf("This is free software, and you are welcome " + "to redistribute it\n"); + printf("under certain conditions; read the GNU GPL for details.\n"); /* get the amount of memory */ get_memory_map(); @@ -128,11 +126,9 @@ #ifdef BLOB_DEBUG { - register u32 stackptr; - SerialOutputString("Current stack pointer: 0x"); + register unsigned int stackptr; asm("mov %0, sp": "=r" (stackptr)); - SerialOutputHex(stackptr); - serial_write('\n'); + printf("Current stack pointer: 0x%08x\n", stackptr); } #endif @@ -152,9 +148,9 @@ int retval = 0; /* wait 10 seconds before starting autoboot */ - SerialOutputString("Autoboot ("); - SerialOutputDec(blob_status.boot_delay); - SerialOutputString(" seconds) in progress, press any key to stop "); + printf("Autoboot (%i seconds) in progress, press any key to stop ", + blob_status.boot_delay); + for(i = 0; i < blob_status.boot_delay; i++) { serial_write('.'); @@ -170,8 +166,8 @@ parse_command("boot"); } - SerialOutputString("\nAutoboot aborted\n"); - SerialOutputString("Type \"help\" to get a list of commands\n"); + printf("\nAutoboot aborted\n"); + printf("Type \"help\" to get a list of commands\n"); } /* the command loop. endless, of course */ @@ -268,26 +264,26 @@ return 0; if (blob_status.terminalSpeed != blob_status.downloadSpeed) { - SerialOutputString("Switching to "); + printf("Switching to "); PrintSerialSpeed(blob_status.downloadSpeed); - SerialOutputString(" baud\n"); + printf(" baud\n"); - SerialOutputString("You have 60 seconds to switch your terminal emulator to the same speed and\n"); - SerialOutputString("start downloading. After that " PACKAGE " will switch back to "); + printf("You have 60 seconds to switch your terminal emulator to the same speed and\n"); + printf("start downloading. After that " PACKAGE " will switch back to "); PrintSerialSpeed(blob_status.terminalSpeed); - SerialOutputString(" baud.\n"); + printf(" baud.\n"); serial_init(blob_status.downloadSpeed); } else { - SerialOutputString("You have 60 seconds to start downloading.\n"); + printf("You have 60 seconds to start downloading.\n"); } *numRead = UUDecode((char *)startAddress, bufLen); if (blob_status.terminalSpeed != blob_status.downloadSpeed) { - SerialOutputString("\n(Please switch your terminal emulator back to "); + printf("\n(Please switch your terminal emulator back to "); PrintSerialSpeed(blob_status.terminalSpeed); - SerialOutputString(" baud)\n"); + printf(" baud)\n"); } if(*numRead < 0) { @@ -303,20 +299,15 @@ do_md5sum((u32 *)startAddress, *numRead, digest); - SerialOutputString("Received "); - SerialOutputDec(*numRead); - SerialOutputString(" (0x"); - SerialOutputHex(*numRead); - SerialOutputString(") bytes"); + printf("Received %i (0x%08x) bytes", *numRead, *numRead); #ifdef BLOB_DEBUG - SerialOutputString(" at 0x"); - SerialOutputHex((u32) startAddress); + printf("at 0x%08x", (unsigned int)startAddress); #ifdef CONFIG_MD5_SUPPORT - SerialOutputString(", MD5: "); + printf(", MD5: "); print_md5_digest(digest); #endif #endif - serial_write('\n'); + printf("\n"); serial_init(blob_status.terminalSpeed); @@ -349,29 +340,30 @@ return 0; if (blob_status.terminalSpeed != blob_status.downloadSpeed) { - SerialOutputString("Switching to "); + printf("Switching to "); PrintSerialSpeed(blob_status.downloadSpeed); - SerialOutputString(" baud\n"); + printf(" baud\n"); - SerialOutputString("Switch your terminal emulator to the same speed and\n"); - SerialOutputString("start sending using the XMODEM protocl (repeated ^X) to quit.\n"); - SerialOutputString(PACKAGE " will switch back to "); + printf("Switch your terminal emulator to the same speed and\n"); + printf("start sending using the XMODEM protocol (repeated ^X) to quit.\n"); + printf(PACKAGE " will switch back to "); PrintSerialSpeed(blob_status.terminalSpeed); - SerialOutputString(" baud after XMODEM succeeds or times out.\n"); + printf(" baud after XMODEM succeeds or times out.\n"); serial_init(blob_status.downloadSpeed); } else { - SerialOutputString("Start sending using the XMODEM protocol (repeated ^X to quit).\n\n"); + printf("Start sending using the XMODEM protocol (repeated ^X to quit).\n\n"); } *numRead = XModemReceive((char *) startAddress, bufLen); - SerialOutputString("\n\n\n"); + printf("\n\n\n"); + serial_flush_output(); if (blob_status.terminalSpeed != blob_status.downloadSpeed) { - SerialOutputString("\n(Please switch your terminal emulator back to "); + printf("\n(Please switch your terminal emulator back to "); PrintSerialSpeed(blob_status.terminalSpeed); - SerialOutputString(" baud)\n"); + printf(" baud)\n"); } if(*numRead < 0) { @@ -387,20 +379,15 @@ do_md5sum((u32 *)startAddress, *numRead, digest); - SerialOutputString("Received "); - SerialOutputDec(*numRead); - SerialOutputString(" (0x"); - SerialOutputHex(*numRead); - SerialOutputString(") bytes"); + printf("Received %i (0x%08x) bytes", *numRead, *numRead); #ifdef BLOB_DEBUG - SerialOutputString(" at 0x"); - SerialOutputHex((u32) startAddress); + printf("at 0x%08x", (unsigned int)startAddress); #ifdef CONFIG_MD5_SUPPORT - SerialOutputString(", MD5: "); + printf(", MD5: "); print_md5_digest(digest); #endif #endif - serial_write('\n'); + printf("\n"); serial_init(blob_status.terminalSpeed); @@ -467,28 +454,21 @@ if(type == fromFlash) { printerrprefix(); - SerialOutputString(argv[1]); - SerialOutputString(" not downloaded\n"); + printf("%s not downloaded\n", argv[1]); return -EINVAL; } if(numBytes > maxSize) { printerrprefix(); - SerialOutputString("image too large for flash: 0x"); - SerialOutputHex(numBytes); - SerialOutputString(" > 0x"); - SerialOutputHex(maxSize); - serial_write('\n'); + printf("image too large for flash: 0x%08x > 0x%08x\n", + (unsigned int)numBytes, (unsigned int)maxSize); return -ETOOLONG; } nwords = (numBytes + sizeof(u32) - 1) / sizeof(u32); - SerialOutputString("Saving "); - SerialOutputString(argv[1]); - SerialOutputString(" to flash\n"); - + printf("Saving %s to flash\n", argv[1]); flash_write_region(dst, src, nwords); @@ -540,9 +520,9 @@ return -EINVAL; } - SerialOutputString("Download speed set to "); + printf("Download speed set to "); PrintSerialSpeed(blob_status.downloadSpeed); - SerialOutputString(" baud\n"); + printf(" baud\n"); return 0; } @@ -559,89 +539,69 @@ static int PrintStatus(int argc, char *argv[]) { - SerialOutputString(version_str); + printf(version_str); - SerialOutputString("Download speed : "); + printf("Download speed : "); PrintSerialSpeed(blob_status.downloadSpeed); - SerialOutputString(" baud\n"); + printf(" baud\n"); - SerialOutputString("Terminal speed : "); + printf("Terminal speed : "); PrintSerialSpeed(blob_status.terminalSpeed); - SerialOutputString(" baud\n"); + printf(" baud\n"); - SerialOutputString("blob (0x"); - SerialOutputHex(BLOB_FLASH_BASE); - SerialOutputString("): "); + printf("blob (0x%08x): ", BLOB_FLASH_BASE); if(blob_status.blobType == fromFlash) { - SerialOutputString("from flash\n"); + printf("from flash\n"); } else { - SerialOutputString("downloaded at 0x"); - SerialOutputHex(BLOB_RAM_BASE); - SerialOutputString(", "); - SerialOutputDec(blob_status.blobSize); - SerialOutputString(" bytes\n"); + printf("downloaded at 0x%08x, %i bytes\n", + BLOB_RAM_BASE, blob_status.blobSize); #ifdef CONFIG_MD5_SUPPORT - SerialOutputString(" MD5: "); + printf(" MD5: "); print_md5_digest(blob_status.blob_md5_digest); - serial_write('\n'); + printf("\n"); #endif } #ifdef PARAM_START - SerialOutputString("param (0x"); - SerialOutputHex(PARAM_FLASH_BASE); - SerialOutputString("): "); + printf("param (0x%08x): ", PARAM_FLASH_BASE); if(blob_status.paramType == fromFlash) { - SerialOutputString("from flash\n"); + printf("from flash\n"); } else { - SerialOutputString("downloaded at 0x"); - SerialOutputHex(PARAM_RAM_BASE); - SerialOutputString(", "); - SerialOutputDec(blob_status.paramSize); - SerialOutputString(" bytes\n"); + printf("downloaded at 0x%08x, %i bytes\n", + PARAM_RAM_BASE, blob_status.paramSize); #ifdef CONFIG_MD5_SUPPORT - SerialOutputString(" MD5: "); + printf(" MD5: "); print_md5_digest(blob_status.param_md5_digest); - serial_write('\n'); + printf("\n"); #endif } #else - SerialOutputString("param : Not available\n"); + printf("param : Not available\n"); #endif - SerialOutputString("kernel (0x"); - SerialOutputHex(KERNEL_FLASH_BASE); - SerialOutputString("): "); + printf("kernel (0x%08x): ", KERNEL_FLASH_BASE); if(blob_status.kernelType == fromFlash) { - SerialOutputString("from flash\n"); + printf("from flash\n"); } else { - SerialOutputString("downloaded at 0x"); - SerialOutputHex(KERNEL_RAM_BASE); - SerialOutputString(", "); - SerialOutputDec(blob_status.kernelSize); - SerialOutputString(" bytes\n"); + printf("downloaded at 0x%08x, %i bytes\n", + KERNEL_RAM_BASE, blob_status.kernelSize); #ifdef CONFIG_MD5_SUPPORT - SerialOutputString(" MD5: "); + printf(" MD5: "); print_md5_digest(blob_status.kernel_md5_digest); - serial_write('\n'); + printf("\n"); #endif } - SerialOutputString("ramdisk (0x"); - SerialOutputHex(RAMDISK_FLASH_BASE); - SerialOutputString("): "); + printf("ramdisk (0x%08x): ", RAMDISK_FLASH_BASE); if(blob_status.ramdiskType == fromFlash) { - SerialOutputString("from flash\n"); + printf("from flash\n"); } else { - SerialOutputString("downloaded at 0x"); - SerialOutputHex(RAMDISK_RAM_BASE); - SerialOutputString(", "); - SerialOutputDec(blob_status.ramdiskSize); - SerialOutputString(" bytes\n"); + printf("downloaded at 0x%08x, %i bytes\n", + RAMDISK_RAM_BASE, blob_status.ramdiskSize); #ifdef CONFIG_MD5_SUPPORT - SerialOutputString(" MD5: "); + printf(" MD5: "); print_md5_digest(blob_status.ramdisk_md5_digest); - serial_write('\n'); + printf("\n"); #endif } @@ -668,7 +628,7 @@ numWords = BLOB_FLASH_LEN / 4; blob_status.blobSize = 0; blob_status.blobType = fromFlash; - SerialOutputString("Loading blob from flash "); + printf("Loading blob from flash "); #ifdef PARAM_START } else if(strncmp(what, "param", 6) == 0) { dst = (u32 *)PARAM_RAM_BASE; @@ -676,7 +636,7 @@ numWords = PARAM_FLASH_LEN / 4; blob_status.paramSize = 0; blob_status.paramType = fromFlash; - SerialOutputString("Loading paramater block from flash "); + printf("Loading paramater block from flash "); #endif } else if(strncmp(what, "kernel", 7) == 0) { dst = (u32 *)KERNEL_RAM_BASE; @@ -684,21 +644,21 @@ numWords = KERNEL_FLASH_LEN / 4; blob_status.kernelSize = 0; blob_status.kernelType = fromFlash; - SerialOutputString("Loading kernel from flash "); + printf("Loading kernel from flash "); } else if(strncmp(what, "ramdisk", 8) == 0) { dst = (u32 *)RAMDISK_RAM_BASE; src = (u32 *)RAMDISK_FLASH_BASE; numWords = RAMDISK_FLASH_LEN / 4; blob_status.ramdiskSize = 0; blob_status.ramdiskType = fromFlash; - SerialOutputString("Loading ramdisk from flash "); + printf("Loading ramdisk from flash "); } else { printerror(EINVAL, what); return 0; } MyMemCpy(dst, src, numWords); - SerialOutputString(" done\n"); + printf(" done\n"); return 0; } @@ -724,39 +684,44 @@ static void PrintSerialSpeed(serial_baud_t speed) { + int tmp; + switch(speed) { case baud_1200: - SerialOutputDec(1200); + tmp = 1200; break; case baud_9600: - SerialOutputDec(9600); + tmp = 9600; break; case baud_19200: - SerialOutputDec(19200); + tmp = 19200; break; case baud_38400: - SerialOutputDec(38400); + tmp = 38400; break; case baud_57600: - SerialOutputDec(57600); + tmp = 57600; break; case baud_115200: - SerialOutputDec(115200); + tmp = 115200; break; case baud_230400: - SerialOutputDec(230400); + tmp = 230400; break; default: - SerialOutputString("(unknown)"); + printf("(unknown)"); + return; break; } + + printf("%i", tmp); } @@ -776,15 +741,13 @@ extern u32 __bss_start, __bss_end; extern u32 __stack_start, __stack_end; - SerialOutputString("ELF sections layout:\n"); + printf("ELF sections layout:\n"); #define PRINT_ELF_SECTION(from, to, name) \ - SerialOutputString(" 0x"); \ - SerialOutputHex((u32)&(from)); \ - SerialOutputString(" - 0x"); \ - SerialOutputHex((u32)&(to)); \ - SerialOutputString(" " name "\n"); - + printf(" 0x%08x - 0x%08x %s\n", \ + (unsigned int)&(from), \ + (unsigned int)&(to), \ + name); PRINT_ELF_SECTION(__text_start, __text_end, ".text"); PRINT_ELF_SECTION(__rodata_start, __rodata_end, ".rodata"); Index: linux.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/linux.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- linux.c 6 Jan 2002 15:46:17 -0000 1.8 +++ linux.c 8 Feb 2002 12:55:16 -0000 1.9 @@ -32,7 +32,6 @@ #include <blob/main.h> #include <blob/memory.h> #include <blob/util.h> -#include <blob/serial.h> #include <asm-arm/setup.h> @@ -60,7 +59,7 @@ setup_end_tag(); /* we assume that the kernel is in place */ - SerialOutputString("\nStarting kernel ...\n\n"); + printf("\nStarting kernel ...\n\n"); serial_flush_output(); /* disable subsystems that want to be disabled before kernel boot */ @@ -69,7 +68,7 @@ /* start kernel */ theKernel(0, ARCH_NUMBER); - SerialOutputString("Hey, the kernel returned! This should not happen.\n"); + printf("Hey, the kernel returned! This should not happen.\n"); return 0; } |