Changeset 4872160 in mainline for boot/genarch


Ignore:
Timestamp:
2010-05-04T10:44:55Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
568db0f
Parents:
bb252ca
Message:

new boot infrastructure

  • more code and metadata unification
  • import of up-to-date implementations from the kernel
  • the boot loaders should behave more similarly on all platforms
  • support for deflate compressed (LZ77) boot components
    • this again allows feasible boot images to be created on mips32
  • IA64 is still not booting
    • the broken forked GNU EFI library has been removed, a replacement of the functionality is on its way
Location:
boot/genarch
Files:
3 added
3 deleted
5 moved

Legend:

Unmodified
Added
Removed
  • boot/genarch/include/division.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2007 Michal Kebrt
    3  * Copyright (c) 2009 Vineeth Pillai
     2 * Copyright (c) 2006 Josef Cejka
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
     29/** @file
     30 */
    3031
    31 /** @addtogroup arm32boot
    32  * @{
    33  */
    34 /** @file
    35  *  @brief bootloader output logic
    36  */
     32#ifndef BOOT_DIVISION_H_
     33#define BOOT_DIVISION_H_
    3734
     35/* 32bit integer division */
     36extern int __divsi3(int, int);
    3837
    39 #include <printf.h>
     38/* 64bit integer division */
     39extern long long __divdi3(long long, long long);
    4040
     41/* 32bit unsigned integer division */
     42extern unsigned int __udivsi3(unsigned int, unsigned int);
    4143
    42 /** Address where characters to be printed are expected. */
    43 #ifdef MACHINE_testarm
    44         #define PUTC_ADDRESS  0x10000000
     44/* 64bit unsigned integer division */
     45extern unsigned long long __udivdi3(unsigned long long, unsigned long long);
     46
     47/* 32bit remainder of the signed division */
     48extern int __modsi3(int, int);
     49
     50/* 64bit remainder of the signed division */
     51extern long long __moddi3(long long, long long);
     52
     53/* 32bit remainder of the unsigned division */
     54extern unsigned int __umodsi3(unsigned int, unsigned int);
     55
     56/* 64bit remainder of the unsigned division */
     57extern unsigned long long __umoddi3(unsigned long long, unsigned long long);
     58
     59extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long,
     60    unsigned long long *);
     61
    4562#endif
    46 
    47 #ifdef MACHINE_integratorcp
    48         #define PUTC_ADDRESS  0x16000000
    49 #endif
    50 
    51 
    52 
    53 /** Prints a character to the console.
    54  *
    55  * @param ch Character to be printed.
    56  */
    57 static void putc(char ch)
    58 {
    59         if (ch == '\n')
    60                 *((volatile char *) PUTC_ADDRESS) = '\r';
    61         *((volatile char *) PUTC_ADDRESS) = ch;
    62 }
    63 
    64 
    65 /** Prints a string to the console.
    66  *
    67  * @param str String to be printed.
    68  * @param len Number of characters to be printed.
    69  */
    70 void write(const char *str, const int len)
    71 {
    72         int i;
    73         for (i = 0; i < len; ++i) {
    74                 putc(str[i]);
    75         }
    76 }
    7763
    7864/** @}
    7965 */
    80 
  • boot/genarch/include/multiplication.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2009 Josef Cejka
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef BOOT_sparc64_STACK_H_
    30 #define BOOT_sparc64_STACK_H_
     29/**
     30 * @file
     31 */
    3132
    32 #define STACK_ALIGNMENT              16
    33 #define STACK_BIAS                   2047
    34 #define STACK_WINDOW_SAVE_AREA_SIZE  (16 * 8)
     33#ifndef BOOT_MULTIPLICATION_H__
     34#define BOOT_MULTIPLICATION_H__
     35
     36/* 64 bit multiplication */
     37extern long long __muldi3(long long, long long);
    3538
    3639#endif
     40
     41/** @}
     42 */
     43
     44
  • boot/genarch/include/ofw.h

    rbb252ca r4872160  
    3030#define BOOT_OFW_H_
    3131
    32 #include <types.h>
     32#include <typedefs.h>
    3333#include <stdarg.h>
    3434
     
    4141
    4242typedef unative_t ofw_arg_t;
    43 typedef unsigned int ihandle;
    44 typedef unsigned int phandle;
     43typedef native_t ofw_ret_t;
     44typedef uint32_t ofw_prop_t;
     45typedef uint32_t ihandle;
     46typedef uint32_t phandle;
    4547
    4648/** OpenFirmware command structure
     
    5658typedef struct {
    5759        void *start;
    58         uint32_t size;
     60        size_t size;
    5961} memzone_t;
    6062
    6163typedef struct {
    62         uint32_t total;
    63         uint32_t count;
     64        uint64_t total;
     65        size_t cnt;
    6466        memzone_t zones[MEMMAP_MAX_RECORDS];
    6567} memmap_t;
     
    8789extern void ofw_init(void);
    8890
    89 extern void ofw_write(const char *str, const int len);
     91extern void ofw_putchar(const char);
    9092
    91 extern int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen);
    92 extern int ofw_get_proplen(const phandle device, const char *name);
    93 extern int ofw_next_property(const phandle device, char *previous, char *buf);
     93extern ofw_arg_t ofw_get_property(const phandle, const char *, void *,
     94    const size_t);
     95extern ofw_arg_t ofw_get_proplen(const phandle, const char *);
     96extern ofw_arg_t ofw_next_property(const phandle, char *, char *);
    9497
    95 extern phandle ofw_get_child_node(const phandle node);
    96 extern phandle ofw_get_peer_node(const phandle node);
    97 extern phandle ofw_find_device(const char *name);
     98extern phandle ofw_get_child_node(const phandle);
     99extern phandle ofw_get_peer_node(const phandle);
     100extern phandle ofw_find_device(const char *);
    98101
    99 extern int ofw_package_to_path(const phandle device, char *buf, const int buflen);
     102extern ofw_arg_t ofw_package_to_path(const phandle, char *, const size_t);
    100103
    101 extern int ofw(ofw_args_t *arg);
    102 extern unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...);
    103 extern unsigned int ofw_get_address_cells(const phandle device);
    104 extern unsigned int ofw_get_size_cells(const phandle device);
    105 extern void *ofw_translate(const void *virt);
    106 extern int ofw_translate_failed(ofw_arg_t flag);
    107 extern void *ofw_claim_virt(const void *virt, const unsigned int len);
    108 extern void *ofw_claim_phys(const void *virt, const unsigned int len);
    109 extern void *ofw_claim_phys_any(const unsigned int len, const unsigned int alignment);
    110 extern int ofw_map(const void *phys, const void *virt, const unsigned int size, const int mode);
    111 extern int ofw_memmap(memmap_t *map);
     104extern ofw_arg_t ofw(ofw_args_t *);
     105extern ofw_arg_t ofw_call(const char *, const size_t, const size_t, ofw_arg_t *,
     106    ...);
     107
     108extern size_t ofw_get_address_cells(const phandle);
     109extern size_t ofw_get_size_cells(const phandle);
     110
     111extern void *ofw_translate(const void *);
     112
     113extern void ofw_claim_virt(const void *, const size_t);
     114extern void *ofw_claim_virt_any(const size_t, const size_t);
     115
     116extern void ofw_claim_phys(const void *, const size_t);
     117extern void *ofw_claim_phys_any(const size_t, const size_t);
     118
     119extern void ofw_map(const void *, const void *, const size_t,
     120    const ofw_arg_t);
     121
     122extern void ofw_alloc(const char *, void **, void **, const size_t, void *);
     123
     124extern void ofw_memmap(memmap_t *);
    112125extern void ofw_setup_screens(void);
    113126extern void ofw_quiesce(void);
  • boot/genarch/include/ofw_tree.h

    rbb252ca r4872160  
    3030#define BOOT_OFW_TREE_H_
    3131
    32 #include <types.h>
    33 #include <ofw.h>
    34 
     32#include <typedefs.h>
     33#include <genarch/ofw.h>
    3534
    3635/** Memory representation of OpenFirmware device tree node property. */
     
    4746        struct ofw_tree_node *child;
    4847       
    49         uint32_t node_handle;           /**< Old OpenFirmware node handle. */
     48        phandle node_handle;            /**< Old OpenFirmware node handle. */
    5049       
    5150        char *da_name;                  /**< Disambigued name. */
    5251       
    53         unsigned int properties;        /**< Number of properties. */
     52        size_t properties;              /**< Number of properties. */
    5453        ofw_tree_property_t *property;
    5554       
  • boot/genarch/src/ofw_tree.c

    rbb252ca r4872160  
    2727 */
    2828
    29 #include <ofw_tree.h>
    30 #include <ofw.h>
    31 #include <ofwarch.h>
    32 #include <types.h>
    33 #include <string.h>
     29#include <genarch/ofw_tree.h>
     30#include <genarch/ofw.h>
     31#include <arch/ofw.h>
     32#include <typedefs.h>
     33#include <str.h>
    3434#include <balloc.h>
    35 #include <asm.h>
    3635#include <memstr.h>
    3736
     37static char path[OFW_TREE_PATH_MAX_LEN + 1];
     38static char name[OFW_TREE_PROPERTY_MAX_NAMELEN];
     39static char name2[OFW_TREE_PROPERTY_MAX_NAMELEN];
     40
    3841static ofw_tree_node_t *ofw_tree_node_alloc(void)
    3942{
     
    4144}
    4245
    43 static ofw_tree_property_t *ofw_tree_properties_alloc(unsigned count)
     46static ofw_tree_property_t *ofw_tree_properties_alloc(size_t count)
    4447{
    4548        return balloc(count * sizeof(ofw_tree_property_t),
     
    5962         * behind the requested memory.
    6063         */
    61         char *addr = balloc(size + 1, size);
     64        char *addr = balloc(size + 1, 4);
    6265        if (addr)
    6366                addr[size] = '\0';
     
    99102                 * Get the disambigued name.
    100103                 */
    101                 static char path[OFW_TREE_PATH_MAX_LEN + 1];
    102104                size_t len = ofw_package_to_path(current, path, OFW_TREE_PATH_MAX_LEN);
    103                 if (len == -1)
     105                if (len == (size_t) -1)
    104106                        return;
    105107               
     
    107109               
    108110                /* Find last slash */
    109                 int i;
    110                 for (i = len - 1; (i >= 0) && (path[i] != '/'); i--);
     111                size_t i;
     112                for (i = len; (i > 0) && (path[i - 1] != '/'); i--);
    111113               
    112114                /* Do not include the slash */
    113                 i++;
    114115                len -= i;
    115116               
     
    127128                 */
    128129                phandle child = ofw_get_child_node(current);
    129                 if ((child != 0) && (child != -1)) {
     130                if ((child != 0) && (child != (phandle) -1)) {
    130131                        ofw_tree_node_t *child_node = ofw_tree_node_alloc();
    131132                        if (child_node) {
     
    140141                 * Count properties.
    141142                 */
    142                 static char name[OFW_TREE_PROPERTY_MAX_NAMELEN];
    143                 static char name2[OFW_TREE_PROPERTY_MAX_NAMELEN];
    144143                name[0] = '\0';
    145144                while (ofw_next_property(current, name, name2) == 1) {
     
    188187                current_node->property = (ofw_tree_property_t *) balloc_rebase(property);
    189188               
    190                
    191189                /*
    192190                 * Iteratively process the next peer node.
     
    197195                 */
    198196                phandle peer = ofw_get_peer_node(current);
    199                 if ((peer != 0) && (peer != -1)) {
     197                if ((peer != 0) && (peer != (phandle) -1)) {
    200198                        ofw_tree_node_t *peer_node = ofw_tree_node_alloc();
    201199                        if (peer_node) {
     
    234232         */
    235233        phandle ssm_node = ofw_find_device("/ssm@0,0");
    236         if (ssm_node != -1) {
     234        if (ssm_node != (phandle) -1) {
    237235                ofw_tree_node_t *ssm = ofw_tree_node_alloc();
    238236                if (ssm) {
Note: See TracChangeset for help on using the changeset viewer.