PERFORCE change 95455 for review
Warner Losh
imp at FreeBSD.org
Mon Apr 17 21:58:19 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=95455
Change 95455 by imp at imp_hammer on 2006/04/17 21:57:14
checkpoint making bootiic compile with newer, more strict flags.
Affected files ...
.. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/debug_io.c#5 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/debug_io.h#3 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/eeprom.c#5 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/env_vars.c#4 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/loader_prompt.c#5 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/loader_prompt.h#4 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/main.c#4 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/p_string.c#3 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/p_string.h#3 edit
Differences ...
==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/debug_io.c#5 (text+ko) ====
@@ -18,8 +18,9 @@
* END_BLOCK
******************************************************************************/
-#include "at91rm9200.h"
#include "p_string.h"
+#include "debug_io.h"
+#include "lib.h"
/*
* .KB_C_FN_DEFINITION_START
@@ -27,10 +28,12 @@
* This global function writes a string to the debug uart port.
* .KB_C_FN_DEFINITION_END
*/
-void DebugPrint(char *buffer) {
+void
+DebugPrint(const char *buffer)
+{
- if (!buffer) return;
-
+ if (!buffer)
+ return;
while(*buffer != '\0')
putc(*buffer++);
}
@@ -41,12 +44,14 @@
* This global function displays the value with the number of digits specified.
* .KB_C_FN_DEFINITION_END
*/
-void DebugPrintHex(int digits, int value) {
-
+void
+DebugPrintHex(int digits, int value)
+{
char dValue[11], *cPtr;
int nextDigit;
- if ((digits < 1) || (digits > 8)) return ;
+ if ((digits < 1) || (digits > 8))
+ return;
cPtr = &dValue[10];
*cPtr-- = 0;
==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/debug_io.h#3 (text+ko) ====
@@ -21,10 +21,7 @@
#ifndef _DEBUG_IO_H_
#define _DEBUG_IO_H_
-extern void DebugPutc(char cValue);
-extern void DebugPrint(char *buffer);
-extern int DebugGetchar(char *retChar);
-extern int WaitForChar(char *cPtr, int seconds);
+extern void DebugPrint(const char *buffer);
extern void DebugPrintHex(int digits, int value);
#endif
==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/eeprom.c#5 (text+ko) ====
@@ -22,6 +22,7 @@
#include "at91rm9200_lowlevel.h"
#include "eeprom.h"
#include "at91rm9200.h"
+#include "debug_io.h"
/* ****************************** GLOBALS *************************************/
==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/env_vars.c#4 (text+ko) ====
@@ -49,7 +49,8 @@
* terminated. Returns 0 to indicate _wait_ condition.
* .KB_C_FN_DEFINITION_END
*/
-static int ReadCharFromEnvironment(int timeout)
+static int
+ReadCharFromEnvironment(int timeout)
{
int ch;
@@ -76,8 +77,9 @@
* memory.
* .KB_C_FN_DEFINITION_END
*/
-void WriteCommandTable(void) {
-
+void
+WriteCommandTable(void)
+{
int i, size = MAX_ENV_SIZE_BYTES, copySize;
char *cPtr = env_table;
@@ -109,8 +111,9 @@
* associated command index.
* .KB_C_FN_DEFINITION_END
*/
-void SetBootCommand(int index, char *command) {
-
+void
+SetBootCommand(int index, char *command)
+{
int i;
if ((unsigned)index < MAX_BOOT_COMMANDS) {
@@ -135,9 +138,10 @@
* This global function displays the current boot commands.
* .KB_C_FN_DEFINITION_END
*/
-void DumpBootCommands(void) {
+void
+DumpBootCommands(void)
+{
int i, j;
- char *cPtr;
for (i = 0; i < MAX_BOOT_COMMANDS; ++i) {
DebugPrintHex(2, i);
@@ -162,7 +166,9 @@
* exists in RAM which is larger than the non-volatile space.
* .KB_C_FN_DEFINITION_END
*/
-void LoadBootCommands(void) {
+void
+LoadBootCommands(void)
+{
int index, j, size;
char *cPtr;
@@ -190,8 +196,9 @@
* This global function executes applicable entries in the environment.
* .KB_C_FN_DEFINITION_END
*/
-void ExecuteEnvironmentFunctions(void) {
-
+void
+ExecuteEnvironmentFunctions(void)
+{
currentIndex = 0;
currentOffset = 0;
==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/loader_prompt.c#5 (text+ko) ====
@@ -29,6 +29,7 @@
#endif
#include "emac.h"
#include "loader_prompt.h"
+#include "env_vars.h"
#include "lib.h"
@@ -69,7 +70,9 @@
* This private function packs the test IP info to an unsigned value.
* .KB_C_FN_DEFINITION_END
*/
-static unsigned BuildIP(void) {
+static unsigned
+BuildIP(void)
+{
unsigned p_ip_addr, p_tmp_val;
p_ASCIIToDec(argv[1], &p_ip_addr);
@@ -96,8 +99,9 @@
* This private function converts a command string to a command code.
* .KB_C_FN_DEFINITION_END
*/
-static int StringToCommand(char *cPtr) {
-
+static int
+StringToCommand(char *cPtr)
+{
int i;
for (i = 0; CommandTable[i].command != COMMAND_FINAL_FLAG; ++i)
@@ -116,8 +120,9 @@
* of the first entry to begin restoring space in the inputBuffer.
* .KB_C_FN_DEFINITION_END
*/
-static void RestoreSpace(int startArgc) {
-
+static void
+RestoreSpace(int startArgc)
+{
char *cPtr;
for (startArgc++; startArgc < MAX_COMMAND_PARAMS; startArgc++) {
@@ -134,7 +139,9 @@
* by argv and returns the number of parameters (< 0 on failure).
* .KB_C_FN_DEFINITION_END
*/
-static int BreakCommand(char *buffer) {
+static int
+BreakCommand(char *buffer)
+{
int pCount, cCount, state;
state = pCount = 0;
@@ -173,7 +180,9 @@
* This private function executes matching functions.
* .KB_C_FN_DEFINITION_END
*/
-static void ParseCommand(char *buffer) {
+static void
+ParseCommand(char *buffer)
+{
int argc;
if ((argc = BreakCommand(buffer)) < 1) {
@@ -188,12 +197,14 @@
// copy memory
char *to, *from;
- unsigned size;
+ unsigned toarg, fromarg, size;
if (argc > 3) {
- p_ASCIIToHex(argv[1], (unsigned*)&to);
- p_ASCIIToHex(argv[2], (unsigned*)&from);
- p_ASCIIToHex(argv[3], (unsigned*)&size);
+ p_ASCIIToHex(argv[1], &toarg);
+ p_ASCIIToHex(argv[2], &fromarg);
+ p_ASCIIToHex(argv[3], &size);
+ to = (char *)toarg;
+ from = (char *)fromarg;
p_memcpy(to, from, size);
}
@@ -211,10 +222,12 @@
// execute at address
void (*execAddr)(unsigned, unsigned, unsigned);
+ unsigned addr;
if (argc > 1) {
- p_ASCIIToHex(argv[1], (unsigned*)&execAddr);
+ p_ASCIIToHex(argv[1], &addr);
/* in future, include machtypes (MACH_KB9200 = 612) */
+ execAddr = (void (*)(unsigned, unsigned, unsigned))addr;
(*execAddr)(0, 612, tagAddress);
}
@@ -347,9 +360,11 @@
// download X-modem record at address
char *destAddr = 0;
+ unsigned addr;
if (argc > 1) {
- p_ASCIIToHex(argv[1], (unsigned*)&destAddr);
+ p_ASCIIToHex(argv[1], &addr);
+ destAddr = (char *)addr;
xmodem_rx(destAddr);
}
}
@@ -417,8 +432,9 @@
* the loader will parse.
* .KB_C_FN_DEFINITION_END
*/
-void Bootloader(int(*inputFunction)(int)) {
-
+void
+Bootloader(int(*inputFunction)(int))
+{
int ch = 0;
p_memset((void*)inputBuffer, 0, sizeof(inputBuffer));
==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/loader_prompt.h#4 (text+ko) ====
@@ -43,10 +43,11 @@
typedef struct {
- int command;
- char *c_string;
+ int command;
+ const char *c_string;
} command_entry_t;
-extern void EnterInteractiveBootloader(int(*inputFunction)(int));
+void EnterInteractiveBootloader(int(*inputFunction)(int));
+void Bootloader(int(*inputFunction)(int));
#endif /* _LOADER_PROMPT_H_ */
==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/main.c#4 (text+ko) ====
@@ -25,6 +25,7 @@
#include "at91rm9200_lowlevel.h"
#include "loader_prompt.h"
#include "emac.h"
+#include "lib.h"
/*
* .KB_C_FN_DEFINITION_START
@@ -36,9 +37,9 @@
* from this function.
* .KB_C_FN_DEFINITION_END
*/
-int main(void) {
-
- char l_char;
+int
+main(void)
+{
EMAC_Init();
==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/p_string.c#3 (text+ko) ====
@@ -21,6 +21,7 @@
* END_BLOCK
******************************************************************************/
+#include "p_string.h"
/*
* .KB_C_FN_DEFINITION_START
@@ -29,7 +30,9 @@
* a non-space character.
* .KB_C_FN_DEFINITION_END
*/
-int p_IsWhiteSpace(char cValue) {
+int
+p_IsWhiteSpace(char cValue)
+{
return ((cValue == ' ') ||
(cValue == '\t') ||
(cValue == 0) ||
@@ -44,7 +47,9 @@
* This global function returns the decimal value of the validated hex char.
* .KB_C_FN_DEFINITION_END
*/
-unsigned p_HexCharValue(char cValue) {
+unsigned
+p_HexCharValue(char cValue)
+{
if (cValue < ('9' + 1))
return (cValue - '0');
if (cValue < ('F' + 1))
@@ -60,8 +65,9 @@
* number of bytes to value.
* .KB_C_FN_DEFINITION_END
*/
-void p_memset(char *buffer, char value, int size) {
-
+void
+p_memset(char *buffer, char value, int size)
+{
while (size--)
*buffer++ = value;
}
@@ -74,11 +80,13 @@
* before (not including) the string termination character ('/0').
* .KB_C_FN_DEFINITION_END
*/
-int p_strlen(char *buffer) {
+int
+p_strlen(const char *buffer)
+{
int len = 0;
- if (buffer) {
- while (buffer[len]) len++;
- }
+ if (buffer)
+ while (buffer[len])
+ len++;
return (len);
}
@@ -90,13 +98,12 @@
* after the copy operation (after the '/0').
* .KB_C_FN_DEFINITION_END
*/
-char *p_strcpy(char *to, char *from) {
-
+char *
+p_strcpy(char *to, const char *from)
+{
while (*from)
*to++ = *from++;
-
- *to++ = *from++;
-
+ *to++ = '\0';
return (to);
}
@@ -110,15 +117,15 @@
* NULL-terminated.
* .KB_C_FN_DEFINITION_END
*/
-void p_ASCIIToHex(char *buf, unsigned *value) {
-
+void
+p_ASCIIToHex(const char *buf, unsigned *value)
+{
unsigned lValue = 0;
if ((*buf == '0') && ((buf[1] == 'x') || (buf[1] == 'X')))
buf += 2;
while (*buf) {
-
lValue <<= 4;
lValue += p_HexCharValue(*buf++);
}
@@ -136,12 +143,12 @@
* NULL-terminated.
* .KB_C_FN_DEFINITION_END
*/
-void p_ASCIIToDec(char *buf, unsigned *value) {
+void
+p_ASCIIToDec(const char *buf, unsigned *value)
+{
*value = 0;
-
while (*buf) {
-
*value *= 10;
*value += (*buf++) - '0';
}
@@ -155,7 +162,9 @@
* pointer for the specified number of bytes.
* .KB_C_FN_DEFINITION_END
*/
-void p_memcpy(char *to, char *from, unsigned size) {
+void
+p_memcpy(char *to, const char *from, unsigned size)
+{
while (size--)
*to++ = *from++;
}
@@ -169,9 +178,11 @@
* greater than 0.
* .KB_C_FN_DEFINITION_END
*/
-int p_memcmp(char *to, char *from, unsigned size) {
-
- while ((--size) && (*to++ == *from++)) ;
+int
+p_memcmp(const char *to, const char *from, unsigned size)
+{
+ while ((--size) && (*to++ == *from++))
+ continue;
return (*to != *from);
}
@@ -184,7 +195,9 @@
* Returns 0 if the locations are equal.
* .KB_C_FN_DEFINITION_END
*/
-int p_strcmp(char *to, char *from) {
+int
+p_strcmp(const char *to, const char *from)
+{
while (*to && *from && (*to == *from)) {
++to;
==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/p_string.h#3 (text+ko) ====
@@ -23,15 +23,15 @@
#define ToASCII(x) ((x > 9) ? (x + 'A' - 0xa) : (x + '0'))
-extern int p_IsWhiteSpace(char cValue);
-extern unsigned p_HexCharValue(char cValue);
-extern void p_memset(char *buffer, char value, int size);
-extern int p_strlen(char *buffer);
-extern char *p_strcpy(char *to, char *from);
-extern void p_ASCIIToHex(char *buf, unsigned *value);
-extern void p_ASCIIToDec(char *buf, unsigned *value);
-extern void p_memcpy(char *to, char *from, unsigned size);
-extern int p_memcmp(char *to, char *from, unsigned size);
-extern int p_strcmp(char *to, char *from);
+int p_IsWhiteSpace(char cValue);
+unsigned p_HexCharValue(char cValue);
+void p_memset(char *buffer, char value, int size);
+int p_strlen(const char *buffer);
+char *p_strcpy(char *to, const char *from);
+void p_ASCIIToHex(const char *buf, unsigned *value);
+void p_ASCIIToDec(const char *buf, unsigned *value);
+void p_memcpy(char *to, const char *from, unsigned size);
+int p_memcmp(const char *to, const char *from, unsigned size);
+int p_strcmp(const char *to, const char *from);
#endif /* _P_STRING_H_ */
More information about the p4-projects
mailing list