Changeset 61e90dd in mainline for kernel


Ignore:
Timestamp:
2006-09-19T22:42:57Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
16529d5
Parents:
3abe07f5
Message:

Add balloc() (a.k.a boot allocator):

  • balloc() only needs to know how to allocate memory.
  • Memory allocated via balloc() is supposed to be passed to kernel and never freed by boot itself.
  • make kernel aware of boot allocations

More work on OFW device tree:

  • use balloc() to efficiently and safely allocate memory for the canonical copy of the device tree

sparc64 boot:

  • pass OFW device tree root node pointer to kernel
Location:
kernel
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/include/boot/boot.h

    r3abe07f5 r61e90dd  
    3636#define KERN_sparc64_BOOT_H_
    3737
    38 
    3938#define VMA                     0x400000
    4039#define LMA                     VMA
     
    4342#ifndef __LINKER__
    4443
     44#include <config.h>
    4545#include <arch/types.h>
    4646#include <typedefs.h>
     47#include <genarch/ofw/ofw_tree.h>
    4748
    4849#define TASKMAP_MAX_RECORDS     32
     
    8788} processor_t;
    8889
     90/** Bootinfo structure.
     91 *
     92 * Must be in sync with bootinfo structure used by the boot loader.
     93 */
    8994typedef struct {
    9095        taskmap_t taskmap;
     
    9398        keyboard_t keyboard;
    9499        processor_t processor;
     100        ballocs_t ballocs;
     101        ofw_tree_node_t *ofw_root;
    95102} bootinfo_t;
    96103
  • kernel/arch/sparc64/src/sparc64.c

    r3abe07f5 r61e90dd  
    5252void arch_pre_main(void)
    5353{
    54         /* Setup usermode */
     54        /* Copy init task info. */
    5555        init.cnt = bootinfo.taskmap.count;
    5656       
     
    6161                init.tasks[i].size = bootinfo.taskmap.tasks[i].size;
    6262        }
     63       
     64        /* Copy boot allocations info. */
     65        ballocs.base = bootinfo.ballocs.base;
     66        ballocs.size = bootinfo.ballocs.size;
    6367}
    6468
  • kernel/genarch/Makefile.inc

    r3abe07f5 r61e90dd  
    8888                genarch/src/kbd/scanc_sun.c
    8989endif
     90
     91
     92## OpenFirmware Device Tree
     93ifeq ($(CONFIG_OFW_TREE), y)
     94        GENARCH_SOURCES += \
     95                genarch/src/ofw/ofw_tree,c
     96endif
  • kernel/generic/include/config.h

    r3abe07f5 r61e90dd  
    5656} init_t;
    5757
     58/** Boot allocations.
     59 *
     60 * Allocatations made by the boot that are meant to be used by the kernel
     61 * are all recorded in the ballocs_t type.
     62 */
     63typedef struct {
     64        uintptr_t base;
     65        size_t size;
     66} ballocs_t;
     67
    5868typedef struct {
    5969        count_t cpu_count;              /**< Number of processors detected. */
     
    7080extern config_t config;
    7181extern init_t init;
     82extern ballocs_t ballocs;
    7283
    7384#endif
  • kernel/generic/src/main/main.c

    r3abe07f5 r61e90dd  
    9595};
    9696
     97/** Boot allocations. */
     98ballocs_t ballocs = {
     99        .base = NULL,
     100        .size = 0
     101};
     102
    97103context_t ctx;
    98104
     
    106112size_t hardcoded_kdata_size = 0;        /**< Size of the kernel data in bytes. */
    107113
    108 uintptr_t stack_safe = 0;       /**< Lowest safe stack virtual address */
     114uintptr_t stack_safe = 0;               /**< Lowest safe stack virtual address */
    109115
    110116void main_bsp(void);
     
    152158                if (PA_overlaps(config.stack_base, config.stack_size, init.tasks[i].addr, init.tasks[i].size))
    153159                        config.stack_base = ALIGN_UP(init.tasks[i].addr + init.tasks[i].size, config.stack_size);
     160        }
     161
     162        /* Avoid placing stack on top of boot allocations. */
     163        if (ballocs.size) {
     164                if (PA_overlaps(config.stack_base, config.stack_size, ballocs.base, ballocs.size))
     165                        config.stack_base = ALIGN_UP(ballocs.base + ballocs.size, PAGE_SIZE);
    154166        }
    155167       
  • kernel/generic/src/mm/frame.c

    r3abe07f5 r61e90dd  
    10781078                        frame_mark_unavailable(ADDR2PFN(KA2PA(init.tasks[i].addr)), SIZE2FRAMES(init.tasks[i].size));
    10791079
     1080                if (ballocs.size)
     1081                        frame_mark_unavailable(ADDR2PFN(KA2PA(ballocs.base)), SIZE2FRAMES(ballocs.size));
     1082
    10801083                /* Black list first frame, as allocating NULL would
    10811084                 * fail in some places */
Note: See TracChangeset for help on using the changeset viewer.