Changeset 4872160 in mainline for boot/generic


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/generic
Files:
12 added
3 deleted
9 moved

Legend:

Unmodified
Added
Removed
  • boot/generic/include/align.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2005 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic
    30  * @{
    31  */
    32 /** @file
     29/**
     30 * @file
     31 * @brief Macros for making values and addresses aligned.
    3332 */
    3433
     
    3635#define BOOT_ALIGN_H_
    3736
     37/** Align to the nearest lower address.
     38 *
     39 * @param s Address or size to be aligned.
     40 * @param a Size of alignment, must be power of 2.
     41 */
     42#define ALIGN_DOWN(s, a)  ((s) & ~((a) - 1))
     43
    3844/** Align to the nearest higher address.
    3945 *
    40  * @param addr Address or size to be aligned.
    41  * @param align Size of alignment, must be power of 2.
     46 * @param s Address or size to be aligned.
     47 * @param a Size of alignment, must be power of 2.
    4248 */
    43 #define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
     49#define ALIGN_UP(s, a)  (((s) + ((a) - 1)) & ~((a) - 1))
    4450
    4551#endif
  • boot/generic/include/balloc.h

    rbb252ca r4872160  
    3030#define BOOT_BALLOC_H_
    3131
    32 #include <types.h>
     32#include <typedefs.h>
    3333
    3434typedef struct {
     
    3737} ballocs_t;
    3838
    39 extern void balloc_init(ballocs_t *ball, uintptr_t base, uintptr_t kernel_base);
    40 extern void *balloc(size_t size, size_t alignment);
    41 extern void *balloc_rebase(void *ptr);
     39extern void balloc_init(ballocs_t *, void *, uintptr_t, size_t);
     40extern void *balloc(size_t, size_t);
     41extern void *balloc_rebase(void *);
    4242
    4343#endif
  • boot/generic/include/halt.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef BOOT_ia64_STACK_H_
    30 #define BOOT_ia64_STACK_H_
     29#ifndef BOOT_HALT_H_
     30#define BOOT_HALT_H_
    3131
    32 #define STACK_ALIGNMENT                 16
    33 #define STACK_BIAS                      2047
    34 #define STACK_WINDOW_SAVE_AREA_SIZE     (16*8)
     32extern void halt(void) __attribute__((noreturn));
    3533
    3634#endif
     35
     36/** @}
     37 */
  • boot/generic/include/macros.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2009 Martin Decky
     2 * Copyright (c) 2005 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
    30  * @{
    31  */
    3229/** @file
    3330 */
     
    3734
    3835#define min(a, b)  ((a) < (b) ? (a) : (b))
    39 #define max(a, b)  ((a) > (b) ? (a) : (b))
    4036
    41 #define SIZE2KB(size)  ((size) >> 10)
    42 #define SIZE2MB(size)  ((size) >> 20)
    43 
    44 #define KB2SIZE(kb)  ((kb) << 10)
    45 #define MB2SIZE(mb)  ((mb) << 20)
     37#define isdigit(d)  (((d) >= '0') && ((d) <= '9'))
    4638
    4739#define STRING(arg)      STRING_ARG(arg)
  • boot/generic/include/memstr.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2009 Martin Decky
     2 * Copyright (c) 2001-2004 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic
    30  * @{
    31  */
    3229/** @file
    3330 */
     
    3633#define BOOT_MEMSTR_H_
    3734
    38 extern void memcpy(void *dst, const void *src, unsigned int cnt);
     35#include <typedefs.h>
     36
     37extern void *memcpy(void *, const void *, size_t);
    3938
    4039#endif
  • boot/generic/include/printf.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2001-2004 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic
    30  * @{
    31  */
    3229/** @file
    3330 */
    3431
    35 #ifndef BOOT_PRINTF_H_
    36 #define BOOT_PRINTF_H_
     32#ifndef BOOT_PRINT_H_
     33#define BOOT_PRINT_H_
    3734
    38 #define INT8    1
    39 #define INT16   2
    40 #define INT32   4
    41 #define INT64   8
     35#include <typedefs.h>
     36#include <stdarg.h>
    4237
    43 extern void puts(const char *str);
    44 extern void printf(const char *fmt, ...);
     38#define EOF  (-1)
    4539
    46 extern void write(const char *str, const int len);
     40extern int puts(const char *);
     41extern int printf(const char *, ...);
     42extern int vprintf(const char *, va_list);
    4743
    4844#endif
  • boot/generic/include/putchar.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2001-2004 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef BOOT_GENTYPES_H_
    36 #define BOOT_GENTYPES_H_
     35#ifndef BOOT_PUTCHAR_H_
     36#define BOOT_PUTCHAR_H_
    3737
    38 #define NULL 0
    39 #define false 0
    40 #define true 1
    41 
    42 typedef unsigned long size_t;
     38extern void putchar(const wchar_t);
    4339
    4440#endif
  • boot/generic/include/stdarg.h

    rbb252ca r4872160  
    2727 */
    2828
    29 /** @addtogroup generic
    30  * @{
    31  */
    3229/** @file
    3330 */
    3431
    35 #ifndef STDARG_H__
    36 #define STDARG_H__
     32#ifndef BOOT_STDARG_H__
     33#define BOOT_STDARG_H__
    3734
    3835typedef __builtin_va_list va_list;
    3936
    40 #define va_start(ap, last)   __builtin_va_start(ap, last)
    41 #define va_arg(ap, type)     __builtin_va_arg(ap, type)
    42 #define va_end(ap)           __builtin_va_end(ap)
     37#define va_start(ap, last)  __builtin_va_start(ap, last)
     38#define va_arg(ap, type)    __builtin_va_arg(ap, type)
     39#define va_end(ap)          __builtin_va_end(ap)
    4340
    4441#endif
  • boot/generic/src/balloc.c

    rbb252ca r4872160  
    2828
    2929#include <balloc.h>
    30 #include <asm.h>
    31 #include <types.h>
     30#include <typedefs.h>
    3231#include <align.h>
    3332
    3433static ballocs_t *ballocs;
    3534static uintptr_t phys_base;
     35static size_t max_size;
    3636
    37 void balloc_init(ballocs_t *ball, uintptr_t base, uintptr_t kernel_base)
     37void balloc_init(ballocs_t *ball, void *base, uintptr_t kernel_base,
     38    size_t size)
    3839{
    3940        ballocs = ball;
    40         phys_base = base;
     41        phys_base = (uintptr_t) base;
     42        max_size = size;
    4143        ballocs->base = kernel_base;
    4244        ballocs->size = 0;
     
    4547void *balloc(size_t size, size_t alignment)
    4648{
     49        if (alignment == 0)
     50                return NULL;
     51       
    4752        /* Enforce minimal alignment. */
    4853        alignment = ALIGN_UP(alignment, 4);
     
    5055        uintptr_t addr = phys_base + ALIGN_UP(ballocs->size, alignment);
    5156       
    52         if (ALIGN_UP(ballocs->size, alignment) + size > BALLOC_MAX_SIZE)
     57        if (ALIGN_UP(ballocs->size, alignment) + size >= max_size)
    5358                return NULL;
    5459       
Note: See TracChangeset for help on using the changeset viewer.