Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177667
b: refs/heads/master
c: 02d748a
h: refs/heads/master
i:
  177665: 69008b3
  177663: b4eb24f
v: v3
  • Loading branch information
Albert Herranz authored and Grant Likely committed Dec 13, 2009
1 parent 803b301 commit 762d9ad
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d1d56f8c1d5a622228177eca47e9dcff0498bddb
refs/heads/master: 02d748a9ee56735641bade9b734dc2fa9be4df4c
118 changes: 115 additions & 3 deletions trunk/arch/powerpc/boot/wii.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,120 @@

BSS_STACK(8192);

#define HW_REG(x) ((void *)(x))
#define HW_REG(x) ((void *)(x))

#define EXI_CTRL HW_REG(0x0d800070)
#define EXI_CTRL_ENABLE (1<<0)
#define EXI_CTRL HW_REG(0x0d800070)
#define EXI_CTRL_ENABLE (1<<0)

#define MEM2_TOP (0x10000000 + 64*1024*1024)
#define FIRMWARE_DEFAULT_SIZE (12*1024*1024)


struct mipc_infohdr {
char magic[3];
u8 version;
u32 mem2_boundary;
u32 ipc_in;
size_t ipc_in_size;
u32 ipc_out;
size_t ipc_out_size;
};

static int mipc_check_address(u32 pa)
{
/* only MEM2 addresses */
if (pa < 0x10000000 || pa > 0x14000000)
return -EINVAL;
return 0;
}

static struct mipc_infohdr *mipc_get_infohdr(void)
{
struct mipc_infohdr **hdrp, *hdr;

/* 'mini' header pointer is the last word of MEM2 memory */
hdrp = (struct mipc_infohdr **)0x13fffffc;
if (mipc_check_address((u32)hdrp)) {
printf("mini: invalid hdrp %08X\n", (u32)hdrp);
hdr = NULL;
goto out;
}

hdr = *hdrp;
if (mipc_check_address((u32)hdr)) {
printf("mini: invalid hdr %08X\n", (u32)hdr);
hdr = NULL;
goto out;
}
if (memcmp(hdr->magic, "IPC", 3)) {
printf("mini: invalid magic\n");
hdr = NULL;
goto out;
}

out:
return hdr;
}

static int mipc_get_mem2_boundary(u32 *mem2_boundary)
{
struct mipc_infohdr *hdr;
int error;

hdr = mipc_get_infohdr();
if (!hdr) {
error = -1;
goto out;
}

if (mipc_check_address(hdr->mem2_boundary)) {
printf("mini: invalid mem2_boundary %08X\n",
hdr->mem2_boundary);
error = -EINVAL;
goto out;
}
*mem2_boundary = hdr->mem2_boundary;
error = 0;
out:
return error;

}

static void platform_fixups(void)
{
void *mem;
u32 reg[4];
u32 mem2_boundary;
int len;
int error;

mem = finddevice("/memory");
if (!mem)
fatal("Can't find memory node\n");

/* two ranges of (address, size) words */
len = getprop(mem, "reg", reg, sizeof(reg));
if (len != sizeof(reg)) {
/* nothing to do */
goto out;
}

/* retrieve MEM2 boundary from 'mini' */
error = mipc_get_mem2_boundary(&mem2_boundary);
if (error) {
/* if that fails use a sane value */
mem2_boundary = MEM2_TOP - FIRMWARE_DEFAULT_SIZE;
}

if (mem2_boundary > reg[2] && mem2_boundary < reg[2] + reg[3]) {
reg[3] = mem2_boundary - reg[2];
printf("top of MEM2 @ %08X\n", reg[2] + reg[3]);
setprop(mem, "reg", reg, sizeof(reg));
}

out:
return;
}

void platform_init(unsigned long r3, unsigned long r4, unsigned long r5)
{
Expand All @@ -42,5 +152,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5)

if (ug_probe())
console_ops.write = ug_console_write;

platform_ops.fixups = platform_fixups;
}

0 comments on commit 762d9ad

Please sign in to comment.