armlinux.c: refactor
- remove ifdeffery - make locally used functions static - coding style cleanup Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
5e1067792b
commit
6df1e4b20a
|
@ -41,71 +41,93 @@
|
|||
#include <asm/u-boot-arm.h>
|
||||
|
||||
static struct tag *params;
|
||||
|
||||
#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
|
||||
defined (CONFIG_CMDLINE_TAG) || \
|
||||
defined (CONFIG_INITRD_TAG) || \
|
||||
defined (CONFIG_SERIAL_TAG) || \
|
||||
defined (CONFIG_REVISION_TAG) || \
|
||||
defined (CONFIG_LCD) || \
|
||||
defined (CONFIG_VFD)
|
||||
static void __setup_start_tag(void);
|
||||
static void __setup_end_tag(void);
|
||||
#define setup_start_tag __setup_start_tag
|
||||
#define setup_end_tag __setup_end_tag
|
||||
#else
|
||||
#define setup_start_tag() do {} while(0)
|
||||
#define setup_end_tag() do {} while(0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CMDLINE_TAG
|
||||
static void __setup_commandline_tag(const char *commandline);
|
||||
#define setup_commandline_tag __setup_commandline_tag
|
||||
#else
|
||||
#define setup_commandline_tag(a) do {} while(0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SETUP_MEMORY_TAGS
|
||||
static void __setup_memory_tags(void);
|
||||
#define setup_memory_tags __setup_memory_tags
|
||||
#else
|
||||
#define setup_memory_tags() do {} while(0)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifdef CONFIG_INITRD_TAG
|
||||
static void __setup_initrd_tag(ulong initrd_start, ulong initrd_end);
|
||||
#define setup_initrd_tag __setup_initrd_tag
|
||||
#else
|
||||
#define setup_initrd_tag(a,b) do {} while(0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern ulong calc_fbsize(void);
|
||||
#if defined (CONFIG_VFD) || defined (CONFIG_LCD)
|
||||
static void __setup_videolfb_tag(gd_t *gd);
|
||||
#define setup_videolfb_tag __setup_videolfb_tag
|
||||
#else
|
||||
#define setup_videolfb_tag(a) do {} while(0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_REVISION_TAG
|
||||
static void __setup_revision_tag(struct tag **in_params);
|
||||
#define setup_revision_tag __setup_revision_tag
|
||||
#else
|
||||
#define setup_revision_tag(a) do {} while(0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SERIAL_TAG
|
||||
void __setup_serial_tag(struct tag **tmp);
|
||||
#define setup_serial tag __setup_serial_tag
|
||||
#else
|
||||
#define setup_serial_tag(a) do {} while(0)
|
||||
#endif
|
||||
|
||||
static int armlinux_architecture = 0;
|
||||
static void *armlinux_bootparams = NULL;
|
||||
|
||||
static void setup_start_tag(void)
|
||||
{
|
||||
params = (struct tag *)armlinux_bootparams;
|
||||
|
||||
params->hdr.tag = ATAG_CORE;
|
||||
params->hdr.size = tag_size(tag_core);
|
||||
|
||||
params->u.core.flags = 0;
|
||||
params->u.core.pagesize = 0;
|
||||
params->u.core.rootdev = 0;
|
||||
|
||||
params = tag_next(params);
|
||||
}
|
||||
|
||||
struct arm_memory {
|
||||
struct list_head list;
|
||||
struct device_d *dev;
|
||||
};
|
||||
|
||||
static LIST_HEAD(memory_list);
|
||||
|
||||
static void setup_memory_tags(void)
|
||||
{
|
||||
struct arm_memory *mem;
|
||||
|
||||
list_for_each_entry(mem, &memory_list, list) {
|
||||
params->hdr.tag = ATAG_MEM;
|
||||
params->hdr.size = tag_size(tag_mem32);
|
||||
|
||||
params->u.mem.start = mem->dev->map_base;
|
||||
params->u.mem.size = mem->dev->size;
|
||||
|
||||
params = tag_next(params);
|
||||
}
|
||||
}
|
||||
|
||||
static void setup_commandline_tag(const char *commandline)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if (!commandline)
|
||||
return;
|
||||
|
||||
/* eat leading white space */
|
||||
for (p = commandline; *p == ' '; p++) ;
|
||||
|
||||
/*
|
||||
* skip non-existent command lines so the kernel will still
|
||||
* use its default command line.
|
||||
*/
|
||||
if (*p == '\0')
|
||||
return;
|
||||
|
||||
params->hdr.tag = ATAG_CMDLINE;
|
||||
params->hdr.size =
|
||||
(sizeof (struct tag_header) + strlen(p) + 1 + 4) >> 2;
|
||||
|
||||
strcpy(params->u.cmdline.cmdline, p);
|
||||
|
||||
params = tag_next(params);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void setup_initrd_tag(ulong initrd_start, ulong initrd_end)
|
||||
{
|
||||
/* an ATAG_INITRD node tells the kernel where the compressed
|
||||
* ramdisk can be found. ATAG_RDIMG is a better name, actually.
|
||||
*/
|
||||
params->hdr.tag = ATAG_INITRD2;
|
||||
params->hdr.size = tag_size(tag_initrd);
|
||||
|
||||
params->u.initrd.start = initrd_start;
|
||||
params->u.initrd.size = initrd_end - initrd_start;
|
||||
|
||||
params = tag_next(params);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void setup_end_tag (void)
|
||||
{
|
||||
params->hdr.tag = ATAG_NONE;
|
||||
params->hdr.size = 0;
|
||||
}
|
||||
|
||||
void armlinux_set_bootparams(void *params)
|
||||
{
|
||||
armlinux_bootparams = params;
|
||||
|
@ -116,13 +138,6 @@ void armlinux_set_architecture(int architecture)
|
|||
armlinux_architecture = architecture;
|
||||
}
|
||||
|
||||
struct arm_memory {
|
||||
struct list_head list;
|
||||
struct device_d *dev;
|
||||
};
|
||||
|
||||
static LIST_HEAD(memory_list);
|
||||
|
||||
void armlinux_add_dram(struct device_d *dev)
|
||||
{
|
||||
struct arm_memory *mem = xzalloc(sizeof(*mem));
|
||||
|
@ -136,7 +151,7 @@ int do_bootm_linux(struct image_data *data)
|
|||
{
|
||||
void (*theKernel)(int zero, int arch, void *params);
|
||||
image_header_t *os_header = &data->os->header;
|
||||
const char *commandline = getenv ("bootargs");
|
||||
const char *commandline = getenv("bootargs");
|
||||
|
||||
if (os_header->ih_type == IH_TYPE_MULTI) {
|
||||
printf("Multifile images not handled at the moment\n");
|
||||
|
@ -156,28 +171,25 @@ int do_bootm_linux(struct image_data *data)
|
|||
printf("commandline: %s\n"
|
||||
"arch_number: %d\n", commandline, armlinux_architecture);
|
||||
|
||||
theKernel = (void (*)(int, int, void *))ntohl((unsigned long)(os_header->ih_ep));
|
||||
theKernel = (void *)ntohl(os_header->ih_ep);
|
||||
|
||||
debug ("## Transferring control to Linux (at address %08lx) ...\n",
|
||||
(ulong) theKernel);
|
||||
debug("## Transferring control to Linux (at address 0x%p) ...\n",
|
||||
theKernel);
|
||||
|
||||
setup_start_tag();
|
||||
setup_serial_tag(¶ms);
|
||||
setup_revision_tag(¶ms);
|
||||
setup_memory_tags();
|
||||
setup_commandline_tag(commandline);
|
||||
#if 0
|
||||
if (initrd_start && initrd_end)
|
||||
setup_initrd_tag (initrd_start, initrd_end);
|
||||
#endif
|
||||
setup_videolfb_tag((gd_t *) gd);
|
||||
setup_end_tag();
|
||||
|
||||
if (relocate_image(data->os, (void *)ntohl(os_header->ih_load)))
|
||||
return -1;
|
||||
|
||||
/* we assume that the kernel is in place */
|
||||
printf ("\nStarting kernel ...\n\n");
|
||||
printf("\nStarting kernel ...\n\n");
|
||||
|
||||
cleanup_before_linux();
|
||||
theKernel (0, armlinux_architecture, armlinux_bootparams);
|
||||
|
@ -213,89 +225,6 @@ static int armlinux_register_image_handler(void)
|
|||
|
||||
late_initcall(armlinux_register_image_handler);
|
||||
|
||||
void
|
||||
__setup_start_tag(void)
|
||||
{
|
||||
params = (struct tag *)armlinux_bootparams;
|
||||
|
||||
params->hdr.tag = ATAG_CORE;
|
||||
params->hdr.size = tag_size(tag_core);
|
||||
|
||||
params->u.core.flags = 0;
|
||||
params->u.core.pagesize = 0;
|
||||
params->u.core.rootdev = 0;
|
||||
|
||||
params = tag_next(params);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__setup_memory_tags(void)
|
||||
{
|
||||
struct arm_memory *mem;
|
||||
|
||||
list_for_each_entry(mem, &memory_list, list) {
|
||||
params->hdr.tag = ATAG_MEM;
|
||||
params->hdr.size = tag_size(tag_mem32);
|
||||
|
||||
params->u.mem.start = mem->dev->map_base;
|
||||
params->u.mem.size = mem->dev->size;
|
||||
|
||||
params = tag_next(params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__setup_commandline_tag(const char *commandline)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if (!commandline)
|
||||
return;
|
||||
|
||||
/* eat leading white space */
|
||||
for (p = commandline; *p == ' '; p++) ;
|
||||
|
||||
/*
|
||||
* skip non-existent command lines so the kernel will still
|
||||
* use its default command line.
|
||||
*/
|
||||
if (*p == '\0')
|
||||
return;
|
||||
|
||||
params->hdr.tag = ATAG_CMDLINE;
|
||||
params->hdr.size =
|
||||
(sizeof (struct tag_header) + strlen(p) + 1 + 4) >> 2;
|
||||
|
||||
strcpy(params->u.cmdline.cmdline, p);
|
||||
|
||||
params = tag_next(params);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__setup_initrd_tag(ulong initrd_start, ulong initrd_end)
|
||||
{
|
||||
/* an ATAG_INITRD node tells the kernel where the compressed
|
||||
* ramdisk can be found. ATAG_RDIMG is a better name, actually.
|
||||
*/
|
||||
params->hdr.tag = ATAG_INITRD2;
|
||||
params->hdr.size = tag_size(tag_initrd);
|
||||
|
||||
params->u.initrd.start = initrd_start;
|
||||
params->u.initrd.size = initrd_end - initrd_start;
|
||||
|
||||
params = tag_next(params);
|
||||
}
|
||||
|
||||
void
|
||||
__setup_end_tag (void)
|
||||
{
|
||||
params->hdr.tag = ATAG_NONE;
|
||||
params->hdr.size = 0;
|
||||
}
|
||||
|
||||
struct zimage_header {
|
||||
u32 unsused[9];
|
||||
u32 magic;
|
||||
|
@ -343,19 +272,16 @@ static int do_bootz(cmd_tbl_t *cmdtp, int argc, char *argv[])
|
|||
printf("loaded zImage from %s with size %d\n", argv[1], header.end);
|
||||
|
||||
setup_start_tag();
|
||||
setup_serial_tag(¶ms);
|
||||
setup_revision_tag(¶ms);
|
||||
setup_memory_tags();
|
||||
setup_commandline_tag(commandline);
|
||||
#if 0
|
||||
if (initrd_start && initrd_end)
|
||||
setup_initrd_tag (initrd_start, initrd_end);
|
||||
#endif
|
||||
setup_videolfb_tag((gd_t *) gd);
|
||||
setup_end_tag();
|
||||
|
||||
cleanup_before_linux();
|
||||
theKernel (0, armlinux_architecture, armlinux_bootparams);
|
||||
theKernel(0, armlinux_architecture, armlinux_bootparams);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue