forked from luck/tmp_suning_uos_patched
[S390] setup: simplify setup_resources()
Simplify setup_resources() and make it more generic. That way it is easier to add additional resources. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
d0d2e31af6
commit
71189284e6
@ -102,16 +102,6 @@ EXPORT_SYMBOL(lowcore_ptr);
|
|||||||
|
|
||||||
#include <asm/setup.h>
|
#include <asm/setup.h>
|
||||||
|
|
||||||
static struct resource code_resource = {
|
|
||||||
.name = "Kernel code",
|
|
||||||
.flags = IORESOURCE_BUSY | IORESOURCE_MEM,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct resource data_resource = {
|
|
||||||
.name = "Kernel data",
|
|
||||||
.flags = IORESOURCE_BUSY | IORESOURCE_MEM,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* condev= and conmode= setup parameter.
|
* condev= and conmode= setup parameter.
|
||||||
*/
|
*/
|
||||||
@ -436,11 +426,25 @@ setup_lowcore(void)
|
|||||||
lowcore_ptr[0] = lc;
|
lowcore_ptr[0] = lc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init
|
static struct resource code_resource = {
|
||||||
setup_resources(void)
|
.name = "Kernel code",
|
||||||
|
.flags = IORESOURCE_BUSY | IORESOURCE_MEM,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct resource data_resource = {
|
||||||
|
.name = "Kernel data",
|
||||||
|
.flags = IORESOURCE_BUSY | IORESOURCE_MEM,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct resource __initdata *standard_resources[] = {
|
||||||
|
&code_resource,
|
||||||
|
&data_resource,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void __init setup_resources(void)
|
||||||
{
|
{
|
||||||
struct resource *res, *sub_res;
|
struct resource *res, *std_res, *sub_res;
|
||||||
int i;
|
int i, j;
|
||||||
|
|
||||||
code_resource.start = (unsigned long) &_text;
|
code_resource.start = (unsigned long) &_text;
|
||||||
code_resource.end = (unsigned long) &_etext - 1;
|
code_resource.end = (unsigned long) &_etext - 1;
|
||||||
@ -450,7 +454,7 @@ setup_resources(void)
|
|||||||
for (i = 0; i < MEMORY_CHUNKS; i++) {
|
for (i = 0; i < MEMORY_CHUNKS; i++) {
|
||||||
if (!memory_chunk[i].size)
|
if (!memory_chunk[i].size)
|
||||||
continue;
|
continue;
|
||||||
res = alloc_bootmem_low(sizeof(struct resource));
|
res = alloc_bootmem_low(sizeof(*res));
|
||||||
res->flags = IORESOURCE_BUSY | IORESOURCE_MEM;
|
res->flags = IORESOURCE_BUSY | IORESOURCE_MEM;
|
||||||
switch (memory_chunk[i].type) {
|
switch (memory_chunk[i].type) {
|
||||||
case CHUNK_READ_WRITE:
|
case CHUNK_READ_WRITE:
|
||||||
@ -464,40 +468,24 @@ setup_resources(void)
|
|||||||
res->name = "reserved";
|
res->name = "reserved";
|
||||||
}
|
}
|
||||||
res->start = memory_chunk[i].addr;
|
res->start = memory_chunk[i].addr;
|
||||||
res->end = memory_chunk[i].addr + memory_chunk[i].size - 1;
|
res->end = res->start + memory_chunk[i].size - 1;
|
||||||
request_resource(&iomem_resource, res);
|
request_resource(&iomem_resource, res);
|
||||||
|
|
||||||
if (code_resource.start >= res->start &&
|
for (j = 0; j < ARRAY_SIZE(standard_resources); j++) {
|
||||||
code_resource.start <= res->end &&
|
std_res = standard_resources[j];
|
||||||
code_resource.end > res->end) {
|
if (std_res->start < res->start ||
|
||||||
sub_res = alloc_bootmem_low(sizeof(struct resource));
|
std_res->start > res->end)
|
||||||
memcpy(sub_res, &code_resource,
|
continue;
|
||||||
sizeof(struct resource));
|
if (std_res->end > res->end) {
|
||||||
sub_res->end = res->end;
|
sub_res = alloc_bootmem_low(sizeof(*sub_res));
|
||||||
code_resource.start = res->end + 1;
|
*sub_res = *std_res;
|
||||||
request_resource(res, sub_res);
|
sub_res->end = res->end;
|
||||||
|
std_res->start = res->end + 1;
|
||||||
|
request_resource(res, sub_res);
|
||||||
|
} else {
|
||||||
|
request_resource(res, std_res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code_resource.start >= res->start &&
|
|
||||||
code_resource.start <= res->end &&
|
|
||||||
code_resource.end <= res->end)
|
|
||||||
request_resource(res, &code_resource);
|
|
||||||
|
|
||||||
if (data_resource.start >= res->start &&
|
|
||||||
data_resource.start <= res->end &&
|
|
||||||
data_resource.end > res->end) {
|
|
||||||
sub_res = alloc_bootmem_low(sizeof(struct resource));
|
|
||||||
memcpy(sub_res, &data_resource,
|
|
||||||
sizeof(struct resource));
|
|
||||||
sub_res->end = res->end;
|
|
||||||
data_resource.start = res->end + 1;
|
|
||||||
request_resource(res, sub_res);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data_resource.start >= res->start &&
|
|
||||||
data_resource.start <= res->end &&
|
|
||||||
data_resource.end <= res->end)
|
|
||||||
request_resource(res, &data_resource);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user