aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Lohoff <flo@rfc822.org>2008-11-29 12:08:25 +0000
committerGuido G√ľnther <agx@sigxcpu.org>2009-04-26 15:26:27 +0200
commit4ce5705be57a10598775d14cc1b8a6296df9c653 (patch)
tree8982084754b728117285e7490db0d54968c56928
parent2cd245ada4d4e7f457b6852c146260dd30f154ca (diff)
Clean up usage of CHAR, Boolean, False, True in generic code
-rw-r--r--ext2load/arcboot.h11
-rw-r--r--ext2load/conffile.c14
-rw-r--r--ext2load/loader.c42
-rw-r--r--tip22/tftpload.c50
4 files changed, 52 insertions, 65 deletions
diff --git a/ext2load/arcboot.h b/ext2load/arcboot.h
index e65dc8c..deffaa8 100644
--- a/ext2load/arcboot.h
+++ b/ext2load/arcboot.h
@@ -8,17 +8,10 @@
#include <version.h>
/* loader.c */
-extern CHAR *OSLoadPartition;
-extern CHAR *OSLoadFilename;
-extern CHAR *OSLoadOptions;
-
-typedef enum { False = 0, True } Boolean;
-
-Boolean OpenFile(const char *partition, const char *filename, ext2_file_t* file);
-void Fatal(const CHAR * message, ...);
+int OpenFile(const char *partition, const char *filename, ext2_file_t* file);
/* conffile.c */
-CHAR** ReadConfFile(char **partition, const char *filename, char* config);
+char **ReadConfFile(char **partition, const char *filename, char* config);
/* ext2io.c */
extern int arc_do_progress;
diff --git a/ext2load/conffile.c b/ext2load/conffile.c
index 75c771f..6eb475c 100644
--- a/ext2load/conffile.c
+++ b/ext2load/conffile.c
@@ -9,13 +9,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <types.h>
#include <sys/types.h>
#include <ext2_fs.h>
#include <ext2fs.h>
#include "arcboot.h"
-#include <arc.h>
#define _PARM_LIMIT 32
@@ -26,7 +24,7 @@ static char *carray[_PARM_LIMIT+4]; /* 0 is the name,
X+1 ... _PARM_LIMIT are options given on the
command line */
-CHAR** GetConfig(char* config, char* name)
+char** GetConfig(char* config, char* name)
{
char *t, *start, *end;
int i;
@@ -115,7 +113,7 @@ CHAR** GetConfig(char* config, char* name)
return NULL;
}
-CHAR** ReadConfFile(char** partition, const char *filename, char* label)
+char** ReadConfFile(char** partition, const char *filename, char* label)
{
ext2_file_t file;
unsigned size, num_read;
@@ -123,22 +121,22 @@ CHAR** ReadConfFile(char** partition, const char *filename, char* label)
char *conf_file;
if(!OpenFile( *partition, filename, &file ))
- return False;
+ return 0;
size = ext2fs_file_get_size(file);
conf_file = malloc(size);
if( !conf_file ) {
printf("Can't read configuration file - not enough memory\n\r");
- return False;
+ return 0;
}
status = ext2fs_file_read(file,(char*) conf_file, size, &num_read);
if( status ) {
print_ext2fs_error(status);
- return False;
+ return 0;
}
if( size != num_read ) {
printf("Wanted: %u, got %u bytes of configuration file\n\r", size, num_read);
- return False;
+ return 0;
}
return GetConfig(conf_file, label);
}
diff --git a/ext2load/loader.c b/ext2load/loader.c
index 6eb1682..236c82f 100644
--- a/ext2load/loader.c
+++ b/ext2load/loader.c
@@ -9,11 +9,9 @@
#include <string.h>
#include <stdint.h>
-#include <arc.h>
#include <prom.h>
#include <elf.h>
-#include <sys/types.h>
#include <ext2_fs.h>
#include <ext2fs.h>
@@ -137,7 +135,7 @@ int LoadProgramSegments64(ext2_file_t file, Elf_Ehdr * header, void *segments)
arc_do_progress = 1;
status = ext2fs_file_read(file,
- (void *) (KSEG0ADDR((ULONG)
+ (void *) (KSEG0ADDR((unsigned long)
segment->p_vaddr)),
segment->p_filesz, NULL);
arc_do_progress = 0;
@@ -146,15 +144,15 @@ int LoadProgramSegments64(ext2_file_t file, Elf_Ehdr * header, void *segments)
prom_fatal("Cannot read program segment\n\r");
}
- size = (ULONG)segment->p_memsz - (ULONG)segment->p_filesz;
+ size = (unsigned long)segment->p_memsz - (unsigned long)segment->p_filesz;
if (size > 0) {
printf
("Zeroing memory at 0x%lx, size = 0x%lx\n\r",
- (KSEG0ADDR((ULONG)segment->p_vaddr +
- (ULONG)segment->p_filesz)), size);
+ (KSEG0ADDR((unsigned long)segment->p_vaddr +
+ (unsigned long)segment->p_filesz)), size);
memset((void *)
- (KSEG0ADDR((ULONG)segment->p_vaddr +
- (ULONG)segment->p_filesz)), 0, size);
+ (KSEG0ADDR((unsigned long)segment->p_vaddr +
+ (unsigned long)segment->p_filesz)), 0, size);
}
loaded = 1;
@@ -169,7 +167,7 @@ int LoadProgramSegments64(ext2_file_t file, Elf_Ehdr * header, void *segments)
void LoadProgramSegments(ext2_file_t file, Elf_Ehdr * header)
{
- Boolean loaded = False;
+ int loaded = 0;
void *segments;
size_t size;
errcode_t status;
@@ -278,7 +276,7 @@ Elf64_Addr LoadKernelFile(ext2_file_t file)
}
-Boolean OpenFile(const char *partition, const char *filename, ext2_file_t* file)
+int OpenFile(const char *partition, const char *filename, ext2_file_t* file)
{
extern io_manager arc_io_manager;
ext2_filsys fs;
@@ -290,22 +288,22 @@ Boolean OpenFile(const char *partition, const char *filename, ext2_file_t* file)
status = ext2fs_open(partition, 0, 0, 0, arc_io_manager, &fs);
if (status != 0) {
print_ext2fs_error(status);
- return False;
+ return 0;
}
status = ext2fs_namei_follow
(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, filename, &file_inode);
if (status != 0) {
print_ext2fs_error(status);
- return False;
+ return 0;
}
status = ext2fs_file_open(fs, file_inode, 0, file);
if (status != 0) {
print_ext2fs_error(status);
- return False;
+ return 0;
}
- return True;
+ return 1;
}
Elf64_Addr LoadKernel(const char *partition, const char *filename)
@@ -321,7 +319,7 @@ Elf64_Addr LoadKernel(const char *partition, const char *filename)
void LoadInitrd(const char *partition, const char *filename)
{
ext2_file_t file;
- ULONG initrd_addr, initrd_sz;
+ unsigned long initrd_addr, initrd_sz;
int status;
if (!OpenFile(partition, filename, &file))
@@ -329,7 +327,7 @@ void LoadInitrd(const char *partition, const char *filename)
initrd_sz = ext2fs_file_get_size(file);
- initrd_addr = (ULONG)malloc(initrd_sz + max_page_size);
+ initrd_addr = (unsigned long)malloc(initrd_sz + max_page_size);
if (initrd_addr == 0) {
prom_fatal("Cannot allocate memory for initrd\n\r");
@@ -357,7 +355,7 @@ void LoadInitrd(const char *partition, const char *filename)
}
-void printCmdLine(int argc, CHAR *argv[])
+void printCmdLine(int argc, char *argv[])
{
int i;
@@ -365,7 +363,7 @@ void printCmdLine(int argc, CHAR *argv[])
printf("%u: %s\n\r", i, argv[i]);
}
-void _start64(LONG argc, CHAR * argv[], CHAR * envp[],
+void _start64(long argc, char *argv[], char *envp[],
unsigned long long *addr)
{
__asm__ __volatile__(
@@ -381,10 +379,10 @@ void _start64(LONG argc, CHAR * argv[], CHAR * envp[],
"\t.set pop": : "r" (addr), "r" (argc), "r" (argv) : "$4", "$5");
}
-void _start(LONG argc, CHAR *argv[], CHAR *envp[])
+void _start(int argc, char *argv[], char *envp[])
{
- CHAR **nargv;
- CHAR **params;
+ char **nargv;
+ char **params;
char *bootpartition, *label, *kernelfile=NULL, *initrdfile=NULL;
int nargc, nopt;
@@ -446,7 +444,7 @@ void _start(LONG argc, CHAR *argv[], CHAR *envp[])
if(is64==0) {
printf("Starting ELF32 kernel\n\r");
prom_flush_cache_all();
- ((void (*)(int argc, CHAR * argv[], CHAR * envp[]))
+ ((void (*)(int argc, char *argv[], char *envp[]))
kernel_entry32)(kargc ,kargv, envp);
} else {
printf("Starting ELF64 kernel\n\r");
diff --git a/tip22/tftpload.c b/tip22/tftpload.c
index 2d649a0..ed31e15 100644
--- a/tip22/tftpload.c
+++ b/tip22/tftpload.c
@@ -24,8 +24,6 @@
#define ANSI_CLEAR "\033[2J"
-typedef enum { False = 0, True } Boolean;
-
extern void* __kernel_start;
extern void* __kernel_end;
extern void* __rd_start;
@@ -34,18 +32,18 @@ extern void* __rd_end;
/* convert an offset in the kernel image to an address in the loaded tftpboot image */
static void* offset2addr(unsigned long offset)
{
- void* address = (void*)((ULONG)&(__kernel_start) + offset);
+ void* address = (void*)((unsigned long)&(__kernel_start) + offset);
return address;
}
/* copy program segments to the locations the kernel expects */
-static ULONG CopyProgramSegments32(Elf32_Ehdr * header)
+static unsigned long CopyProgramSegments32(Elf32_Ehdr * header)
{
int idx;
- Boolean loaded = False;
+ int loaded = 0;
Elf32_Phdr *segment, *segments;
size_t size = header->e_phentsize * header->e_phnum;
- ULONG kernel_end=0L;
+ unsigned long kernel_end=0L;
if (size <= 0)
prom_fatal("No program segments\n\r");
@@ -79,7 +77,7 @@ static ULONG CopyProgramSegments32(Elf32_Ehdr * header)
(KSEG0ADDR(segment->
p_vaddr + segment->p_filesz)), 0, size);
}
- loaded = True;
+ loaded = 1;
}
segment =
(Elf32_Phdr *) (((char *) segment) +
@@ -93,13 +91,13 @@ static ULONG CopyProgramSegments32(Elf32_Ehdr * header)
return kernel_end;
}
-static ULONG CopyProgramSegments64(Elf64_Ehdr * header)
+static unsigned long CopyProgramSegments64(Elf64_Ehdr * header)
{
int idx;
- Boolean loaded = False;
+ int loaded = 0;
Elf64_Phdr *segment, *segments;
- ULONG size = header->e_phentsize * header->e_phnum;
- ULONG kernel_end=0L;
+ unsigned long size = header->e_phentsize * header->e_phnum;
+ unsigned long kernel_end=0L;
if (size <= 0)
prom_fatal("No program segments\n\r");
@@ -126,17 +124,17 @@ static ULONG CopyProgramSegments64(Elf64_Ehdr * header)
kernel_end = segment->p_vaddr + segment->p_memsz;
}
- size = (ULONG)segment->p_memsz - (ULONG)segment->p_filesz;
+ size = (unsigned long)segment->p_memsz - (unsigned long)segment->p_filesz;
if (size > 0) {
printf
("Zeroing memory at 0x%lx, size = 0x%lx\n\r",
- (KSEG0ADDR((ULONG)segment->p_vaddr +
- (ULONG)segment->p_filesz)), size);
+ (KSEG0ADDR((unsigned long)segment->p_vaddr +
+ (unsigned long)segment->p_filesz)), size);
memset((void *)
- (KSEG0ADDR((ULONG)segment->p_vaddr +
- (ULONG)segment->p_filesz)), 0, size);
+ (KSEG0ADDR((unsigned long)segment->p_vaddr +
+ (unsigned long)segment->p_filesz)), 0, size);
}
- loaded = True;
+ loaded = 1;
}
segment =
(Elf64_Phdr *) (((char *) segment) +
@@ -150,7 +148,7 @@ static ULONG CopyProgramSegments64(Elf64_Ehdr * header)
return kernel_end;
}
-static ULONG CopyKernel(ULONG* kernel_end)
+static unsigned long CopyKernel(unsigned long* kernel_end)
{
Elf32_Ehdr *header = (Elf32_Ehdr*)offset2addr(0L);
Elf64_Ehdr *header64 = (Elf64_Ehdr*)header;
@@ -173,7 +171,7 @@ static ULONG CopyKernel(ULONG* kernel_end)
(*kernel_end) = CopyProgramSegments32(header);
printf("Kernel entry point is 0x%lx\n\r",
- ((ULONG) KSEG0ADDR(header->e_entry)));
+ ((unsigned long) KSEG0ADDR(header->e_entry)));
return KSEG0ADDR(header->e_entry);
} else if (header->e_ident[EI_CLASS] == ELFCLASS64) {
if (header64->e_ident[EI_DATA] != ELFDATA2MSB)
@@ -190,7 +188,7 @@ static ULONG CopyKernel(ULONG* kernel_end)
(*kernel_end) = CopyProgramSegments64(header64);
printf("Kernel entry point is 0x%lx\n\r",
- ((ULONG)KSEG0ADDR(header64->e_entry)));
+ ((unsigned long)KSEG0ADDR(header64->e_entry)));
return KSEG0ADDR(header64->e_entry);
} else
prom_fatal("Neither an ELF32 nor an ELF64 kernel\n\r");
@@ -198,7 +196,7 @@ static ULONG CopyKernel(ULONG* kernel_end)
return 0L;
}
-static void copyRamdisk(void* rd_vaddr, void* rd_start, ULONG rd_size)
+static void copyRamdisk(void* rd_vaddr, void* rd_start, unsigned long rd_size)
{
printf("Copying initrd from 0x%p to 0x%p (0x%lx bytes)...\n\r",
rd_start, rd_vaddr, rd_size);
@@ -206,15 +204,15 @@ static void copyRamdisk(void* rd_vaddr, void* rd_start, ULONG rd_size)
printf("Initrd copied.\n\r");
}
-void _start(LONG argc, CHAR * argv[], CHAR * envp[])
+void _start(long argc, char * argv[], char * envp[])
{
char* nargv[3];
int nargc,i;
char argv_rd[128]; /* passed to the kernel on its commandline */
- ULONG kernel_end = 0L;
- ULONG rd_size= ((char*)&__rd_end) - ((char*)&__rd_start);
+ unsigned long kernel_end = 0L;
+ unsigned long rd_size= ((char*)&__rd_end) - ((char*)&__rd_start);
char* rd_vaddr=NULL;
- void (*kernel_entry)(int argc, CHAR * argv[], CHAR * envp[]);
+ void (*kernel_entry)(int argc, char * argv[], char * envp[]);
/* Print identification */
#if (SUBARCH == IP22)
@@ -232,7 +230,7 @@ void _start(LONG argc, CHAR * argv[], CHAR * envp[])
printf("Embedded ramdisk image starts 0x%p, ends 0x%p\n\r",
&__rd_start, &__rd_end);
#endif
- kernel_entry = (void (*)(int, CHAR *[], CHAR *[]))CopyKernel(&kernel_end);
+ kernel_entry = (void (*)(int, char *[], char *[]))CopyKernel(&kernel_end);
/* align to page boundary */
#if (SUBARCH != IP22)