Changeset a7a1063 in mainline


Ignore:
Timestamp:
2005-06-07T00:41:39Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d896525
Parents:
b0bf501
Message:

SMP recovery patch #2 (SMP is no longer broken !!!).
Fix missing KA2PA() operation in ap.S which was causing page faults during AP early initialization.
Fix bug in map_page_to_frame(): 'root' was interpretted as kernel address while read_dba() returns physical address.
Make references to page directory and page tables use kernel addresses instead of physical addresses.

Massive frame allocation code cleanup.
Basically revert to what we had had before implementation of userspace.

Usual cosmetics.

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/boot/boot.S

    rb0bf501 ra7a1063  
    9696        orl $(1<<31), %ebx
    9797        movl %ebx, %cr0
    98         jmp 0f
    99 0:
    10098        ret
    10199
  • arch/ia32/src/mm/frame.c

    rb0bf501 ra7a1063  
    3838{
    3939        if (config.cpu_active == 1) {
    40                 kernel_frames = frames;
    41                 kernel_frames_free = frames_free;
    42                 frame_kernel_bitmap = frame_bitmap;
    43 
    4440                frame_not_free(0x0);
    4541
  • arch/ia32/src/mm/page.c

    rb0bf501 ra7a1063  
    6565                 */
    6666                for (i = 1; i < frames; i++) {
    67                         map_page_to_frame(i * PAGE_SIZE, i * PAGE_SIZE, PAGE_CACHEABLE, dba);
    68                         map_page_to_frame(PA2KA(i * PAGE_SIZE), i * PAGE_SIZE, PAGE_CACHEABLE, dba);
     67                        map_page_to_frame(i * PAGE_SIZE, i * PAGE_SIZE, PAGE_CACHEABLE, KA2PA(dba));
     68                        map_page_to_frame(PA2KA(i * PAGE_SIZE), i * PAGE_SIZE, PAGE_CACHEABLE, KA2PA(dba));
    6969                }
    7070
     
    113113        pte = (page >> 12) & 0x3ff;     /* page table entry */
    114114       
    115         pd = (struct page_specifier *) dba;
     115        pd = (struct page_specifier *) PA2KA(dba);
    116116       
    117117        if (!pd[pde].present) {
     
    127127        }
    128128       
    129         pt = (struct page_specifier *) (pd[pde].frame_address << 12);
     129        pt = (struct page_specifier *) PA2KA((pd[pde].frame_address << 12));
    130130
    131131        pt[pte].frame_address = frame >> 12;
  • arch/ia32/src/pm.c

    rb0bf501 ra7a1063  
    132132void pm_init(void)
    133133{
    134         struct descriptor *gdt_p = (struct descriptor *) gdtr.base;
     134        struct descriptor *gdt_p = (struct descriptor *) PA2KA(gdtr.base);
    135135
    136136        /*
  • arch/ia32/src/smp/ap.S

    rb0bf501 ra7a1063  
    6464        movl $(ctx-0x80000000),%eax     # KA2PA((__address) &ctx)
    6565        movl (%eax),%esp
     66        subl $0x80000000,%esp           # KA2PA(ctx.sp)
    6667
    6768        lidt idtr
  • arch/ia32/src/smp/mps.c

    rb0bf501 ra7a1063  
    393393}
    394394
     395
    395396/*
    396397 * Kernel thread for bringing up application processors. It becomes clear
     
    415416
    416417        /*
    417          * Grab a frame and map its address to page 0. This is a hack which
    418          * accesses data in frame 0. Note that page 0 is not present because
    419          * of nil reference bug catching.
    420          */
    421         frame = frame_alloc(FRAME_KA);
     418         * We need to access data in frame 0.
     419         */
     420        frame = frame_alloc(0);
    422421        map_page_to_frame(frame,0,PAGE_CACHEABLE,0);
    423422
     
    474473                memcopy(gdt, gdt_new, GDT_ITEMS*sizeof(struct descriptor));
    475474                gdtr.base = KA2PA((__address) gdt_new);
    476                
     475
    477476                if (l_apic_send_init_ipi(pr[i].l_apic_id)) {
    478477                        /*
  • arch/mips/src/mm/frame.c

    rb0bf501 ra7a1063  
    3232void frame_arch_init(void)
    3333{
    34         kernel_frames = frames;
    35         kernel_frames_free = frames_free;
    36         frame_kernel_bitmap = frame_bitmap;
    3734}
  • src/mm/frame.c

    rb0bf501 ra7a1063  
    4949count_t frame_bitmap_octets;
    5050
    51 /*
    52  * This is for kernel address space frames (allocated with FRAME_KA).
    53  * Their addresses may not interfere with user address space.
    54  */
    55 __u8 *frame_kernel_bitmap;
    56 count_t kernel_frames;
    57 count_t kernel_frames_free;
    58 
    5951static spinlock_t framelock;
    6052
     
    7870                memsetb((__address) frame_bitmap, frame_bitmap_octets, 0);
    7971                frames_free = frames;
    80 
    81                 /*
    82                  * Will be properly set up by architecture dependent frame init.
    83                  */
    84                 frame_kernel_bitmap = NULL;
    85                 kernel_frames_free = 0;
    86                 kernel_frames = 0;     
    8772        }
    8873
    8974        /*
    90          * No frame allocations/reservations  prior this point.
     75         * No frame allocations/reservations prior this point.
    9176         */
    9277
     
    10994        int i;
    11095        pri_t pri;
    111         __u8 **frame_bitmap_ptr = &frame_bitmap;
    112         count_t *frames_ptr = &frames, *frames_free_ptr = &frames_free;
    113        
    114         if (flags & FRAME_KA) {
    115                 frame_bitmap_ptr = &frame_kernel_bitmap;
    116                 frames_ptr = &kernel_frames;
    117                 frames_free_ptr = &kernel_frames_free;
    118         }
    11996       
    12097loop:
    12198        pri = cpu_priority_high();
    12299        spinlock_lock(&framelock);
    123         if (*frames_free_ptr) {
    124                 for (i=0; i < *frames_ptr; i++) {
     100        if (frames_free) {
     101                for (i=0; i < frames; i++) {
    125102                        int m, n;
    126103               
     
    128105                        n = i % 8;
    129106
    130                         if (((*frame_bitmap_ptr)[m] & (1<<n)) == 0) {
    131                                 (*frame_bitmap_ptr)[m] |= (1<<n);
    132                                 *frames_free_ptr--;
    133                                 if (flags & FRAME_KA) {
    134                                         /*
    135                                          * frames_free_ptr points to kernel_frames_free
    136                                          * It is still necessary to decrement frames_free.
    137                                          */
    138                                         frames_free--;
    139                                 }
     107                        if ((frame_bitmap[m] & (1<<n)) == 0) {
     108                                frame_bitmap[m] |= (1<<n);
     109                                frames_free--;
    140110                                spinlock_unlock(&framelock);
    141111                                cpu_priority_restore(pri);
     
    165135        pri_t pri;
    166136        __u32 frame;
    167         count_t *frames_free_ptr = &frames_free, *frames_ptr = &frames;
    168         __u8 **frame_bitmap_ptr = &frame_bitmap;
    169 
    170         if (IS_KA(addr)) {
    171                 frames_free_ptr = &kernel_frames_free;
    172                 frame_bitmap_ptr = &frame_kernel_bitmap;
    173         }
    174137
    175138        pri = cpu_priority_high();
     
    178141        frame = IS_KA(addr) ? KA2PA(addr) : addr;
    179142        frame /= FRAME_SIZE;
    180         if (frame < *frames_ptr) {
     143        if (frame < frames) {
    181144                int m, n;
    182145       
     
    184147                n = frame % 8;
    185148       
    186                 if ((*frame_bitmap_ptr)[m] & (1<<n)) {
    187                         (*frame_bitmap_ptr)[m] &= ~(1<<n);
    188                         *frames_free_ptr++;
    189                         if (IS_KA(addr)) {
    190                                 /*
    191                                  * frames_free_ptr points to kernel_frames_free
    192                                  * It is still necessary to increment frames_free.
    193                                  */
    194                                  frames_free++;
    195                         }       
     149                if (frame_bitmap[m] & (1<<n)) {
     150                        frame_bitmap[m] &= ~(1<<n);
     151                        frames_free++;
    196152                }
    197153                else panic("frame already free\n");
     
    211167        pri_t pri;
    212168        __u32 frame;
    213         count_t *frames_ptr = &frames, *frames_free_ptr = &frames_free;
    214         __u8 **frame_bitmap_ptr = &frame_bitmap;
    215169       
    216170        pri = cpu_priority_high();
     
    218172        frame = IS_KA(addr) ? KA2PA(addr) : addr;
    219173        frame /= FRAME_SIZE;
    220         if (frame < *frames_ptr) {
     174        if (frame < frames) {
    221175                int m, n;
    222176
     
    224178                n = frame % 8;
    225179       
    226                 if (((*frame_bitmap_ptr)[m] & (1<<n)) == 0) {   
    227                         (*frame_bitmap_ptr)[m] |= (1<<n);
    228                         *frames_free_ptr--;     
    229                         if (IS_KA(addr)) {
    230                                 /*
    231                                  * frames_free_ptr points to kernel_frames_free
    232                                  * It is still necessary to decrement frames_free.
    233                                  */
    234                                 frames_free--;
    235                         }
     180                if ((frame_bitmap[m] & (1<<n)) == 0) { 
     181                        frame_bitmap[m] |= (1<<n);
     182                        frames_free--; 
    236183                }
    237184        }
  • src/proc/scheduler.c

    rb0bf501 ra7a1063  
    4444#include <arch/faddr.h>
    4545#include <arch/atomic.h>
    46 
    47 /*
    48  * NOTE ON ATOMIC READS:
    49  * Some architectures cannot read __u32 atomically.
    50  * For that reason, all accesses to nrdy and the likes must be protected by spinlock.
    51  */
    5246
    5347volatile int nrdy;
Note: See TracChangeset for help on using the changeset viewer.