-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Russell King
committed
Sep 16, 2011
1 parent
a785df8
commit f0ec2d0
Showing
368 changed files
with
907 additions
and
550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 4fb0d2ea397ab207fdecbd88ad0e37b36ce68a62 | ||
refs/heads/master: 4722cd7741c6404f967f7a7b8b666540b6c1663e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#include <asm/setup.h> | ||
#include <libfdt.h> | ||
|
||
static int node_offset(void *fdt, const char *node_path) | ||
{ | ||
int offset = fdt_path_offset(fdt, node_path); | ||
if (offset == -FDT_ERR_NOTFOUND) | ||
offset = fdt_add_subnode(fdt, 0, node_path); | ||
return offset; | ||
} | ||
|
||
static int setprop(void *fdt, const char *node_path, const char *property, | ||
uint32_t *val_array, int size) | ||
{ | ||
int offset = node_offset(fdt, node_path); | ||
if (offset < 0) | ||
return offset; | ||
return fdt_setprop(fdt, offset, property, val_array, size); | ||
} | ||
|
||
static int setprop_string(void *fdt, const char *node_path, | ||
const char *property, const char *string) | ||
{ | ||
int offset = node_offset(fdt, node_path); | ||
if (offset < 0) | ||
return offset; | ||
return fdt_setprop_string(fdt, offset, property, string); | ||
} | ||
|
||
static int setprop_cell(void *fdt, const char *node_path, | ||
const char *property, uint32_t val) | ||
{ | ||
int offset = node_offset(fdt, node_path); | ||
if (offset < 0) | ||
return offset; | ||
return fdt_setprop_cell(fdt, offset, property, val); | ||
} | ||
|
||
/* | ||
* Convert and fold provided ATAGs into the provided FDT. | ||
* | ||
* REturn values: | ||
* = 0 -> pretend success | ||
* = 1 -> bad ATAG (may retry with another possible ATAG pointer) | ||
* < 0 -> error from libfdt | ||
*/ | ||
int atags_to_fdt(void *atag_list, void *fdt, int total_space) | ||
{ | ||
struct tag *atag = atag_list; | ||
uint32_t mem_reg_property[2 * NR_BANKS]; | ||
int memcount = 0; | ||
int ret; | ||
|
||
/* make sure we've got an aligned pointer */ | ||
if ((u32)atag_list & 0x3) | ||
return 1; | ||
|
||
/* if we get a DTB here we're done already */ | ||
if (*(u32 *)atag_list == fdt32_to_cpu(FDT_MAGIC)) | ||
return 0; | ||
|
||
/* validate the ATAG */ | ||
if (atag->hdr.tag != ATAG_CORE || | ||
(atag->hdr.size != tag_size(tag_core) && | ||
atag->hdr.size != 2)) | ||
return 1; | ||
|
||
/* let's give it all the room it could need */ | ||
ret = fdt_open_into(fdt, fdt, total_space); | ||
if (ret < 0) | ||
return ret; | ||
|
||
for_each_tag(atag, atag_list) { | ||
if (atag->hdr.tag == ATAG_CMDLINE) { | ||
setprop_string(fdt, "/chosen", "bootargs", | ||
atag->u.cmdline.cmdline); | ||
} else if (atag->hdr.tag == ATAG_MEM) { | ||
if (memcount >= sizeof(mem_reg_property)/4) | ||
continue; | ||
mem_reg_property[memcount++] = cpu_to_fdt32(atag->u.mem.start); | ||
mem_reg_property[memcount++] = cpu_to_fdt32(atag->u.mem.size); | ||
} else if (atag->hdr.tag == ATAG_INITRD2) { | ||
uint32_t initrd_start, initrd_size; | ||
initrd_start = atag->u.initrd.start; | ||
initrd_size = atag->u.initrd.size; | ||
setprop_cell(fdt, "/chosen", "linux,initrd-start", | ||
initrd_start); | ||
setprop_cell(fdt, "/chosen", "linux,initrd-end", | ||
initrd_start + initrd_size); | ||
} | ||
} | ||
|
||
if (memcount) | ||
setprop(fdt, "/memory", "reg", mem_reg_property, 4*memcount); | ||
|
||
return fdt_pack(fdt); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef _ARM_LIBFDT_ENV_H | ||
#define _ARM_LIBFDT_ENV_H | ||
|
||
#include <linux/types.h> | ||
#include <linux/string.h> | ||
#include <asm/byteorder.h> | ||
|
||
#define fdt16_to_cpu(x) be16_to_cpu(x) | ||
#define cpu_to_fdt16(x) cpu_to_be16(x) | ||
#define fdt32_to_cpu(x) be32_to_cpu(x) | ||
#define cpu_to_fdt32(x) cpu_to_be32(x) | ||
#define fdt64_to_cpu(x) be64_to_cpu(x) | ||
#define cpu_to_fdt64(x) cpu_to_be64(x) | ||
|
||
#endif |
Oops, something went wrong.