Changeset f8ddd17 in mainline for kernel/generic/src/main/main.c


Ignore:
Timestamp:
2006-12-09T20:20:50Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b82a13c
Parents:
9ab9c2ec
Message:

Rework support for virtually indexed cache.
Instead of repeatedly flushing the data cache, which was a huge overkill, refuse to create an illegal address alias
in the kernel (again) and allocate appropriate page color in userspace instead. Extend the detection also to
SYS_PHYSMEM_MAP syscall.

Add support for tracking physical memory areas mappable by SYS_PHYSMEM_MAP.

Lots of coding style changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/main/main.c

    r9ab9c2ec rf8ddd17  
    8181#include <console/klog.h>
    8282#include <smp/smp.h>
     83#include <ddi/ddi.h>
    8384
    8485/** Global configuration structure. */
     
    103104 * appropriate sizes and addresses.
    104105 */
    105 uintptr_t hardcoded_load_address = 0;   /**< Virtual address of where the kernel is loaded. */
    106 size_t hardcoded_ktext_size = 0;        /**< Size of the kernel code in bytes. */
    107 size_t hardcoded_kdata_size = 0;        /**< Size of the kernel data in bytes. */
    108 
    109 uintptr_t stack_safe = 0;               /**< Lowest safe stack virtual address */
     106uintptr_t hardcoded_load_address = 0;   /**< Virtual address of where the kernel
     107                                          *  is loaded. */
     108size_t hardcoded_ktext_size = 0;        /**< Size of the kernel code in bytes.
     109                                          */
     110size_t hardcoded_kdata_size = 0;        /**< Size of the kernel data in bytes.
     111                                         */
     112uintptr_t stack_safe = 0;               /**< Lowest safe stack virtual address.
     113                                          */
    110114
    111115void main_bsp(void);
     
    142146        config.memory_size = get_memory_size();
    143147       
    144         config.kernel_size = ALIGN_UP(hardcoded_ktext_size + hardcoded_kdata_size, PAGE_SIZE);
     148        config.kernel_size = ALIGN_UP(hardcoded_ktext_size +
     149                hardcoded_kdata_size, PAGE_SIZE);
    145150        config.stack_size = CONFIG_STACK_SIZE;
    146151       
     
    151156        count_t i;
    152157        for (i = 0; i < init.cnt; i++) {
    153                 if (PA_overlaps(config.stack_base, config.stack_size, init.tasks[i].addr, init.tasks[i].size))
    154                         config.stack_base = ALIGN_UP(init.tasks[i].addr + init.tasks[i].size, config.stack_size);
     158                if (PA_overlaps(config.stack_base, config.stack_size,
     159                        init.tasks[i].addr, init.tasks[i].size))
     160                        config.stack_base = ALIGN_UP(init.tasks[i].addr +
     161                                init.tasks[i].size, config.stack_size);
    155162        }
    156163
    157164        /* Avoid placing stack on top of boot allocations. */
    158165        if (ballocs.size) {
    159                 if (PA_overlaps(config.stack_base, config.stack_size, ballocs.base, ballocs.size))
    160                         config.stack_base = ALIGN_UP(ballocs.base + ballocs.size, PAGE_SIZE);
     166                if (PA_overlaps(config.stack_base, config.stack_size,
     167                        ballocs.base, ballocs.size))
     168                        config.stack_base = ALIGN_UP(ballocs.base +
     169                                ballocs.size, PAGE_SIZE);
    161170        }
    162171       
     
    165174       
    166175        context_save(&ctx);
    167         context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base, THREAD_STACK_SIZE);
     176        context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base,
     177                THREAD_STACK_SIZE);
    168178        context_restore(&ctx);
    169179        /* not reached */
     
    201211         */     
    202212        arch_pre_mm_init();
    203         frame_init();           /* Initialize at least 1 memory segment big enough for slab to work */
     213        frame_init();           
     214        /* Initialize at least 1 memory segment big enough for slab to work. */
    204215        slab_cache_init();
    205216        btree_init();
     
    207218        page_init();
    208219        tlb_init();
     220        ddi_init();
    209221        arch_post_mm_init();
    210222
    211223        version_print();
    212         printf("kernel: %.*p hardcoded_ktext_size=%zdK, hardcoded_kdata_size=%zdK\n", sizeof(uintptr_t) * 2, config.base, hardcoded_ktext_size >> 10, hardcoded_kdata_size >> 10);
    213         printf("stack:  %.*p size=%zdK\n", sizeof(uintptr_t) * 2, config.stack_base, config.stack_size >> 10);
     224        printf("kernel: %.*p hardcoded_ktext_size=%zdK, "
     225                "hardcoded_kdata_size=%zdK\n", sizeof(uintptr_t) * 2,
     226                config.base, hardcoded_ktext_size >> 10, hardcoded_kdata_size >>
     227                10);
     228        printf("stack:  %.*p size=%zdK\n", sizeof(uintptr_t) * 2,
     229                config.stack_base, config.stack_size >> 10);
    214230
    215231        arch_pre_smp_init();
    216232        smp_init();
    217        
    218         slab_enable_cpucache(); /* Slab must be initialized AFTER we know the number of processors */
     233        /* Slab must be initialized after we know the number of processors. */
     234        slab_enable_cpucache();
    219235
    220236        printf("config.memory_size=%zdM\n", config.memory_size >> 20);
     
    233249        if (init.cnt > 0) {
    234250                for (i = 0; i < init.cnt; i++)
    235                         printf("init[%zd].addr=%.*p, init[%zd].size=%zd\n", i, sizeof(uintptr_t) * 2, init.tasks[i].addr, i, init.tasks[i].size);
     251                        printf("init[%zd].addr=%.*p, init[%zd].size=%zd\n", i,
     252                                sizeof(uintptr_t) * 2, init.tasks[i].addr, i,
     253                                init.tasks[i].size);
    236254        } else
    237255                printf("No init binaries found\n");
     
    305323         * switch to this cpu's private stack prior to waking kmp up.
    306324         */
    307         context_set(&CPU->saved_context, FADDR(main_ap_separated_stack), (uintptr_t) CPU->stack, CPU_STACK_SIZE);
     325        context_set(&CPU->saved_context, FADDR(main_ap_separated_stack),
     326                (uintptr_t) CPU->stack, CPU_STACK_SIZE);
    308327        context_restore(&CPU->saved_context);
    309328        /* not reached */
Note: See TracChangeset for help on using the changeset viewer.