Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 11466
b: refs/heads/master
c: c0a5949
h: refs/heads/master
v: v3
  • Loading branch information
Michael Ellerman authored and Stephen Rothwell committed Sep 23, 2005
1 parent 263cf5b commit 7c7f49e
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f6ab9c68406dfcd1fcd0a5352244fcb932b113b1
refs/heads/master: c0a59491daca7db11d49edad1a1cefaaa7120a9e
137 changes: 137 additions & 0 deletions trunk/arch/ppc64/kernel/iSeries_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,144 @@ struct machdep_calls __initdata iseries_md = {
/* XXX Implement enable_pmcs for iSeries */
};

struct blob {
unsigned char data[PAGE_SIZE];
unsigned long next;
};

struct iseries_flat_dt {
struct boot_param_header header;
u64 reserve_map[2];
struct blob dt;
struct blob strings;
};

struct iseries_flat_dt iseries_dt;

void dt_init(struct iseries_flat_dt *dt)
{
dt->header.off_mem_rsvmap =
offsetof(struct iseries_flat_dt, reserve_map);
dt->header.off_dt_struct = offsetof(struct iseries_flat_dt, dt);
dt->header.off_dt_strings = offsetof(struct iseries_flat_dt, strings);
dt->header.totalsize = sizeof(struct iseries_flat_dt);
dt->header.dt_strings_size = sizeof(struct blob);

/* There is no notion of hardware cpu id on iSeries */
dt->header.boot_cpuid_phys = smp_processor_id();

dt->dt.next = (unsigned long)&dt->dt.data;
dt->strings.next = (unsigned long)&dt->strings.data;

dt->header.magic = OF_DT_HEADER;
dt->header.version = 0x10;
dt->header.last_comp_version = 0x10;

dt->reserve_map[0] = 0;
dt->reserve_map[1] = 0;
}

void dt_check_blob(struct blob *b)
{
if (b->next >= (unsigned long)&b->next) {
DBG("Ran out of space in flat device tree blob!\n");
BUG();
}
}

void dt_push_u32(struct iseries_flat_dt *dt, u32 value)
{
*((u32*)dt->dt.next) = value;
dt->dt.next += sizeof(u32);

dt_check_blob(&dt->dt);
}

void dt_push_u64(struct iseries_flat_dt *dt, u64 value)
{
*((u64*)dt->dt.next) = value;
dt->dt.next += sizeof(u64);

dt_check_blob(&dt->dt);
}

unsigned long dt_push_bytes(struct blob *blob, char *data, int len)
{
unsigned long start = blob->next - (unsigned long)blob->data;

memcpy((char *)blob->next, data, len);
blob->next = _ALIGN(blob->next + len, 4);

dt_check_blob(blob);

return start;
}

void dt_start_node(struct iseries_flat_dt *dt, char *name)
{
dt_push_u32(dt, OF_DT_BEGIN_NODE);
dt_push_bytes(&dt->dt, name, strlen(name) + 1);
}

#define dt_end_node(dt) dt_push_u32(dt, OF_DT_END_NODE)

void dt_prop(struct iseries_flat_dt *dt, char *name, char *data, int len)
{
unsigned long offset;

dt_push_u32(dt, OF_DT_PROP);

/* Length of the data */
dt_push_u32(dt, len);

/* Put the property name in the string blob. */
offset = dt_push_bytes(&dt->strings, name, strlen(name) + 1);

/* The offset of the properties name in the string blob. */
dt_push_u32(dt, (u32)offset);

/* The actual data. */
dt_push_bytes(&dt->dt, data, len);
}

void dt_prop_str(struct iseries_flat_dt *dt, char *name, char *data)
{
dt_prop(dt, name, data, strlen(data) + 1); /* + 1 for NULL */
}

void dt_prop_u32(struct iseries_flat_dt *dt, char *name, u32 data)
{
dt_prop(dt, name, (char *)&data, sizeof(u32));
}

void dt_prop_u64(struct iseries_flat_dt *dt, char *name, u64 data)
{
dt_prop(dt, name, (char *)&data, sizeof(u64));
}

void dt_prop_u64_list(struct iseries_flat_dt *dt, char *name, u64 *data, int n)
{
dt_prop(dt, name, (char *)data, sizeof(u64) * n);
}

void dt_prop_empty(struct iseries_flat_dt *dt, char *name)
{
dt_prop(dt, name, NULL, 0);
}

void build_flat_dt(struct iseries_flat_dt *dt)
{
dt_init(dt);

dt_start_node(dt, "");
dt_end_node(dt);

dt_push_u32(dt, OF_DT_END);
}

void __init iSeries_early_setup(void)
{
iSeries_fixup_klimit();

build_flat_dt(&iseries_dt);
}

0 comments on commit 7c7f49e

Please sign in to comment.