Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1893 → Rev 1894

/trunk/boot/genarch/ofw_tree.h
37,15 → 37,17
typedef struct ofw_tree_node ofw_tree_node_t;
typedef struct ofw_tree_property ofw_tree_property_t;
 
/** Memory representation of OpenFirmware device tree node. */
struct ofw_tree_node {
ofw_tree_node_t *parent;
ofw_tree_node_t *peer;
ofw_tree_node_t *child;
 
unsigned properties;
unsigned properties; /**< Number of properties. */
ofw_tree_property_t *property;
};
 
/** Memory representation of OpenFirmware device tree node property. */
struct ofw_tree_property {
char name[OFW_TREE_PROPERTY_MAX_NAMELEN];
size_t size;
/trunk/boot/genarch/balloc.h
0,0 → 1,42
/*
* Copyright (C) 2006 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef BOOT_BALLOC_H_
#define BOOT_BALLOC_H_
 
#include <types.h>
 
typedef struct {
uintptr_t base;
size_t size;
} ballocs_t;
 
extern void balloc_init(ballocs_t *b, uintptr_t base);
extern void *balloc(size_t size, size_t alignment);
 
#endif
/trunk/boot/genarch/ofw_tree.c
30,20 → 30,21
#include <ofw.h>
#include <types.h>
#include <string.h>
#include <balloc.h>
 
static ofw_tree_node_t *ofw_tree_node_alloc(void)
{
return NULL;
return balloc(sizeof(ofw_tree_node_t), sizeof(ofw_tree_node_t));
}
 
static ofw_tree_property_t *ofw_tree_properties_alloc(unsigned count)
{
return NULL;
return balloc(count * sizeof(ofw_tree_property_t), sizeof(ofw_tree_property_t));
}
 
static void * ofw_tree_space_alloc(size_t size)
{
return NULL;
return balloc(size, size);
}
 
/** Transfer information from one OpenFirmware node into its memory representation.
/trunk/boot/genarch/balloc.c
0,0 → 1,54
/*
* Copyright (C) 2006 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <balloc.h>
#include <types.h>
#include <align.h>
 
static ballocs_t *ballocs;
 
void balloc_init(ballocs_t *b, uintptr_t base)
{
ballocs = b;
ballocs->base = base;
ballocs->size = 0;
}
 
void *balloc(size_t size, size_t alignment)
{
uintptr_t addr;
 
/* Enforce minimal alignment. */
alignment = ALIGN_UP(alignment, 4);
addr = ballocs->base + ALIGN_UP(ballocs->size, alignment);
ballocs->size = ALIGN_UP(ballocs->size, alignment) + size;
return (void *) addr;
}
/trunk/boot/arch/sparc64/loader/main.c
30,7 → 30,9
#include <printf.h>
#include "asm.h"
#include "_components.h"
#include <balloc.h>
#include <ofw.h>
#include <ofw_tree.h>
#include "ofwarch.h"
#include <align.h>
 
83,12 → 85,12
for (i = 0; i < COMPONENTS; i++)
printf(" %P: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
 
void * base = (void *) KERNEL_VIRTUAL_ADDRESS;
unsigned int top = 0;
 
printf("\nCopying components\n");
unsigned int top = 0;
bootinfo.taskmap.count = 0;
for (i = 0; i < COMPONENTS; i++) {
void * base = (void *) KERNEL_VIRTUAL_ADDRESS;
printf(" %s...", components[i].name);
top = ALIGN_UP(top, PAGE_SIZE);
memcpy(base + top, components[i].start, components[i].size);
101,6 → 103,12
printf("done.\n");
}
 
balloc_init(&bootinfo.ballocs, ALIGN_UP(((uintptr_t) base) + top, PAGE_SIZE));
 
printf("\nCanonizing OpenFirmware device tree...");
bootinfo.ofw_root = ofw_tree_build();
printf("done.\n");
 
printf("\nBooting the kernel...\n");
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo));
}
/trunk/boot/arch/sparc64/loader/main.h
30,6 → 30,8
#define BOOT_sparc64_MAIN_H_
 
#include <ofw.h>
#include <ofw_tree.h>
#include <balloc.h>
#include <types.h>
 
#define TASKMAP_MAX_RECORDS 32
54,6 → 56,8
screen_t screen;
keyboard_t keyboard;
cpu_t cpu;
ballocs_t ballocs;
ofw_tree_node_t *ofw_root;
} bootinfo_t;
 
extern void start(void);
/trunk/boot/arch/sparc64/loader/Makefile
52,6 → 52,7
main.c \
../../../generic/printf.c \
../../../generic/string.c \
../../../genarch/balloc.c \
../../../genarch/ofw.c \
../../../genarch/ofw_tree.c \
ofwarch.c \