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;
}