Changeset 00aece0 in mainline for kernel/generic/src/main


Ignore:
Timestamp:
2012-02-18T16:47:38Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4449c6c
Parents:
bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/generic/src/main
Files:
2 edited

Legend:

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

    rbd5f3b7 r00aece0  
    5757#include <mm/as.h>
    5858#include <mm/frame.h>
     59#include <mm/km.h>
    5960#include <print.h>
    6061#include <memstr.h>
     
    6869#include <str.h>
    6970#include <sysinfo/stats.h>
     71#include <align.h>
    7072
    7173#ifdef CONFIG_SMP
     
    178180       
    179181        for (i = 0; i < init.cnt; i++) {
    180                 if (init.tasks[i].addr % FRAME_SIZE) {
    181                         printf("init[%zu].addr is not frame aligned\n", i);
     182                if (init.tasks[i].paddr % FRAME_SIZE) {
     183                        printf("init[%zu]: Address is not frame aligned\n", i);
    182184                        programs[i].task = NULL;
    183185                        continue;
     
    199201                str_cpy(namebuf + INIT_PREFIX_LEN,
    200202                    TASK_NAME_BUFLEN - INIT_PREFIX_LEN, name);
    201                
    202                 int rc = program_create_from_image((void *) init.tasks[i].addr,
    203                     namebuf, &programs[i]);
    204                
    205                 if ((rc == 0) && (programs[i].task != NULL)) {
     203
     204                /*
     205                 * Create virtual memory mappings for init task images.
     206                 */
     207                uintptr_t page = km_map(init.tasks[i].paddr,
     208                    init.tasks[i].size,
     209                    PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
     210                ASSERT(page);
     211               
     212                int rc = program_create_from_image((void *) page, namebuf,
     213                    &programs[i]);
     214               
     215                if (rc == 0) {
     216                        if (programs[i].task != NULL) {
     217                                /*
     218                                 * Set capabilities to init userspace tasks.
     219                                 */
     220                                cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER |
     221                                    CAP_IO_MANAGER | CAP_IRQ_REG);
     222                               
     223                                if (!ipc_phone_0)
     224                                        ipc_phone_0 = &programs[i].task->answerbox;
     225                        }
     226                       
    206227                        /*
    207                          * Set capabilities to init userspace tasks.
     228                         * If programs[i].task == NULL then it is
     229                         * the program loader and it was registered
     230                         * successfully.
    208231                         */
    209                         cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER |
    210                             CAP_IO_MANAGER | CAP_IRQ_REG);
    211                        
    212                         if (!ipc_phone_0)
    213                                 ipc_phone_0 = &programs[i].task->answerbox;
    214                 } else if (rc == 0) {
    215                         /* It was the program loader and was registered */
    216                 } else {
    217                         /* RAM disk image */
    218                         int rd = init_rd((rd_header_t *) init.tasks[i].addr, init.tasks[i].size);
    219                        
    220                         if (rd != RE_OK)
    221                                 printf("Init binary %zu not used (error %d)\n", i, rd);
    222                 }
     232                } else if (i == init.cnt - 1) {
     233                        /*
     234                         * Assume the last task is the RAM disk.
     235                         */
     236                        init_rd((void *) init.tasks[i].paddr, init.tasks[i].size);
     237                } else
     238                        printf("init[%zu]: Init binary load failed (error %d)\n", i, rc);
    223239        }
    224240       
  • kernel/generic/src/main/main.c

    rbd5f3b7 r00aece0  
    6868#include <mm/page.h>
    6969#include <genarch/mm/page_pt.h>
     70#include <mm/km.h>
    7071#include <mm/tlb.h>
    7172#include <mm/as.h>
     
    8687#include <sysinfo/sysinfo.h>
    8788#include <sysinfo/stats.h>
     89#include <lib/ra.h>
    8890
    8991/** Global configuration structure. */
    90 config_t config;
     92config_t config = {
     93        .identity_configured = false,
     94        .non_identity_configured = false,
     95        .physmem_end = 0
     96};
    9197
    9298/** Initial user-space tasks */
     
    145151        size_t i;
    146152        for (i = 0; i < init.cnt; i++) {
    147                 if (PA_OVERLAPS(config.stack_base, config.stack_size,
    148                     init.tasks[i].addr, init.tasks[i].size))
    149                         config.stack_base = ALIGN_UP(init.tasks[i].addr +
    150                             init.tasks[i].size, config.stack_size);
     153                if (overlaps(KA2PA(config.stack_base), config.stack_size,
     154                    init.tasks[i].paddr, init.tasks[i].size)) {
     155                        /*
     156                         * The init task overlaps with the memory behind the
     157                         * kernel image so it must be in low memory and we can
     158                         * use PA2KA on the init task's physical address.
     159                         */
     160                        config.stack_base = ALIGN_UP(
     161                            PA2KA(init.tasks[i].paddr) + init.tasks[i].size,
     162                            config.stack_size);
     163                }
    151164        }
    152165       
     
    205218         */
    206219        arch_pre_mm_init();
     220        km_identity_init();
    207221        frame_init();
    208        
    209         /* Initialize at least 1 memory segment big enough for slab to work. */
    210222        slab_cache_init();
     223        ra_init();     
    211224        sysinfo_init();
    212225        btree_init();
     
    214227        page_init();
    215228        tlb_init();
     229        km_non_identity_init();
    216230        ddi_init();
    217231        arch_post_mm_init();
     
    243257                for (i = 0; i < init.cnt; i++)
    244258                        LOG("init[%zu].addr=%p, init[%zu].size=%zu",
    245                             i, (void *) init.tasks[i].addr, i, init.tasks[i].size);
     259                            i, (void *) init.tasks[i].paddr, i, init.tasks[i].size);
    246260        } else
    247261                printf("No init binaries found.\n");
     
    262276         * Create the first thread.
    263277         */
    264         thread_t *kinit_thread
    265                 = thread_create(kinit, NULL, kernel, 0, "kinit", true);
     278        thread_t *kinit_thread =
     279            thread_create(kinit, NULL, kernel, 0, "kinit", true);
    266280        if (!kinit_thread)
    267281                panic("Cannot create kinit thread.");
Note: See TracChangeset for help on using the changeset viewer.