Changeset 8262010 in mainline


Ignore:
Timestamp:
2005-04-10T16:36:45Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
23c0c08
Parents:
43114c5
Message:

Switch from mm-based 'the' mechanism to macro-based 'cpu_private_data[CPU_ID_ARCH]' mechanism.
Added l_apic_id() and some other minor APIC changes.
Move gdtr to K_DATA_START section.
Move K_DATA_START section immediately behind K_TEXT_START section so that real-mode addresses work even with growing size of kernel code.

Files:
16 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/Makefile.inc

    r43114c5 r8262010  
    1414
    1515CPPFLAGS=$(DEFS) -nostdinc -I../include
    16 CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fomit-frame-pointer -Wmissing-prototypes -Werror -O3
     16CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fomit-frame-pointer -Wmissing-prototypes -Werror -O1
    1717LFLAGS=-M -no-check-sections -T ../arch/ia32/_link.ld
    1818
  • arch/ia32/_link.ld

    r43114c5 r8262010  
    1414        ktext_start = .;
    1515        *(K_TEXT_START);
     16        delta_start = .;
     17        *(K_DATA_START);
     18        delta_end = .;                 
    1619        *(.text);
    1720        ktext_end = .;
    1821
    1922        kdata_start = .;
    20         *(K_DATA_START);
    2123        *(.data);               /* initialized data */
    2224        *(.rodata*);            /* string literals */
     
    2931    . = ABSOLUTE(hardcoded_ktext_size);
    3032    .patch_1 : {
    31         LONG(ktext_end - ktext_start);
     33        LONG(ktext_end - ktext_start - (delta_end - delta_start));
    3234    }
    3335
    3436    . = ABSOLUTE(hardcoded_kdata_size);
    3537    .patch_2 : {
    36         LONG(kdata_end - kdata_start);
     38        LONG(kdata_end - kdata_start + (delta_end - delta_start));
    3739    }
    3840
  • arch/ia32/boot/boot.ld

    r43114c5 r8262010  
     1OUTPUT_FORMAT(binary)
     2ENTRY(main)
    13SECTIONS {
    24    .text 0x7c00 : AT (0x0) { *(.text) }
  • arch/ia32/include/cpu.h

    r43114c5 r8262010  
    3030#define __ia32_CPU_H__
    3131
     32#include <config.h>
    3233#include <typedefs.h>
    3334#include <arch/pm.h>
     35
     36#ifdef __SMP__
     37#define CPU_ID_ARCH     (config.cpu_count>1?l_apic_id():0)
     38#else
     39#define CPU_ID_ARCH     (0)
     40#endif
    3441
    3542struct cpu_arch {
  • arch/ia32/include/smp/apic.h

    r43114c5 r8262010  
    9696#define L_APIC_ID       (0x020/sizeof(__u32))
    9797#define L_APIC_IDClear  (~(0xf<<24))
     98#define L_APIC_IDShift  24
     99#define L_APIC_IDMask   0xf
    98100
    99101/* IO APIC */
     
    121123extern void l_apic_debug(void);
    122124extern void l_apic_timer_interrupt(__u8 n, __u32 stack[]);
     125extern __u8 l_apic_id(void);
    123126
    124127extern __u32 io_apic_read(__u8 address);
  • arch/ia32/src/cpu/cpu.c

    r43114c5 r8262010  
    3535#include <print.h>
    3636#include <typedefs.h>
     37
     38#include <arch/smp/apic.h>
    3739
    3840/*
  • arch/ia32/src/pm.c

    r43114c5 r8262010  
    6767
    6868/* gdtr changes everytime new CPU is initialized */
    69 struct ptr_16_32 gdtr = { .limit = sizeof(gdt), .base = (__address) gdt };
     69struct ptr_16_32 gdtr __attribute__ ((section ("K_DATA_START"))) = { .limit = sizeof(gdt), .base = (__address) gdt };
    7070struct ptr_16_32 idtr = { .limit = sizeof(idt), .base = (__address) idt };
    7171
  • arch/ia32/src/smp/apic.c

    r43114c5 r8262010  
    2727 */
    2828
    29 #ifdef __SMP__
    30 
    3129#include <arch/types.h>
    3230#include <arch/smp/apic.h>
     
    3937#include <arch/asm.h>
    4038#include <arch.h>
     39
     40#ifdef __SMP__
    4141
    4242/*
     
    222222{
    223223        __u32 tmp, t1, t2;
    224        
     224        int cpu_id = config.cpu_active - 1;
     225       
     226
     227        /*
     228         * Here we set local APIC ID's so that they match operating system's CPU ID's
     229         * This operation is dangerous as it is model specific.
     230         * TODO: some care should be taken.
     231         * NOTE: CPU may not be used to define APIC ID
     232         */
     233        if (l_apic_id() != cpu_id) {
     234                l_apic[L_APIC_ID] &= L_APIC_IDClear;
     235                l_apic[L_APIC_ID] |= (l_apic[L_APIC_ID]&L_APIC_IDClear)|((cpu_id)<<L_APIC_IDShift);
     236        }
    225237
    226238        l_apic[LVT_Err] |= (1<<16);
     
    271283        int i, lint;
    272284
    273         printf("LVT on cpu%d, LAPIC ID: %d\n", CPU->id, (l_apic[L_APIC_ID] >> 24)&0xf);
     285        printf("LVT on cpu%d, LAPIC ID: %d\n", CPU->id, l_apic_id());
    274286
    275287        printf("LVT_Tm: ");
     
    305317         * This register is supported only on P6 and higher.
    306318         */
    307         if (CPU->family > 5) {
     319        if (CPU->arch.family > 5) {
    308320                printf("LVT_PCINT: ");
    309321                if (l_apic[LVT_PCINT] & (1<<16)) printf("masked"); else printf("not masked"); putchar(',');
     
    324336        l_apic_eoi();
    325337        clock();
     338}
     339
     340__u8 l_apic_id(void)
     341{
     342        return (l_apic[L_APIC_ID] >> L_APIC_IDShift)&L_APIC_IDMask;
    326343}
    327344
  • arch/mips/include/cpu.h

    r43114c5 r8262010  
    3232#include <typedefs.h>
    3333
     34#define CPU_ID_ARCH     0
     35
    3436struct cpu_arch {
    3537        int imp_num;
  • include/arch.h

    r43114c5 r8262010  
    3434
    3535#include <cpu.h>
     36#include <arch/cpu.h>
    3637
    37 #define CPU             (the->cpu)
    38 #define THREAD          (the->thread)
    39 #define TASK            (the->task)
    40 
    41 extern cpu_private_page_t *the;
     38#define CPU             (cpu_private_data[CPU_ID_ARCH].cpu)
     39#define THREAD          (cpu_private_data[CPU_ID_ARCH].thread)
     40#define TASK            (cpu_private_data[CPU_ID_ARCH].task)
    4241
    4342extern void arch_init(void);
  • include/cpu.h

    r43114c5 r8262010  
    6969};
    7070
    71 struct cpu_private_page {
     71/*
     72 * read/write by associated CPU
     73 * read only by other CPUs
     74 */
     75struct cpu_private_data {
    7276        cpu_t *cpu;
    7377        thread_t *thread;
     
    7579};
    7680
     81extern cpu_private_data_t *cpu_private_data;
    7782extern cpu_t *cpus;
    7883
  • include/typedefs.h

    r43114c5 r8262010  
    3131
    3232typedef struct config config_t;
    33 typedef struct cpu_private_page cpu_private_page_t;
     33typedef struct cpu_private_data cpu_private_data_t;
    3434typedef struct cpu_info cpu_info_t;
    3535
  • src/Makefile.config

    r43114c5 r8262010  
    1212
    1313# Deadlock detection support for spinlocks.
    14 DEBUG_SPINLOCK=DEBUG_SPINLOCK
     14#DEBUG_SPINLOCK=DEBUG_SPINLOCK
    1515
    1616# Uncomment if you want to run in the test mode
  • src/cpu/cpu.c

    r43114c5 r8262010  
    4040#include <list.h>
    4141
    42 cpu_private_page_t *the = NULL;
    43 
     42cpu_private_data_t *cpu_private_data;
    4443cpu_t *cpus;
    4544
     
    5049        if (config.cpu_active == 1) {
    5150        #endif /* __SMP__ */
     51                cpu_private_data = (cpu_private_data_t *) malloc(sizeof(cpu_private_data_t) * config.cpu_count);
     52                if (!cpu_private_data)
     53                        panic("malloc/cpu_private_data");
     54
    5255                cpus = (cpu_t *) malloc(sizeof(cpu_t) * config.cpu_count);
    5356                if (!cpus)
     
    5558
    5659                /* initialize everything */
     60                memsetb((__address) cpu_private_data, sizeof(cpu_private_data_t) * config.cpu_count, 0);
    5761                memsetb((__address) cpus, sizeof(cpu_t) * config.cpu_count, 0);
    5862   
     
    7175                                list_initialize(&cpus[i].rq[j].rq_head);
    7276                        }
     77                       
     78                        cpu_private_data[i].cpu = &cpus[i];
    7379                }
    7480               
    75                 the = (cpu_private_page_t *) frame_alloc(FRAME_KA | FRAME_PANIC);
    76                 memsetb((__address) the, PAGE_SIZE, 0);
    7781        #ifdef __SMP__
    78         }
    79         else {
    80                 __address frame;
    81                
    82                 frame = frame_alloc(FRAME_KA | FRAME_PANIC);
    83                 memsetb(frame, PAGE_SIZE, 0);
    84                 map_page_to_frame((__address) the, frame, PAGE_CACHEABLE, 1);
    8582        }
    8683        #endif /* __SMP__ */
    8784       
    88         CPU = &cpus[config.cpu_active-1];       
    8985        cpu_identify();
    9086        cpu_arch_init();
  • src/main/main.c

    r43114c5 r8262010  
    104104        arch_init();
    105105
     106
    106107        printf("%s, %s\n", project, copyright);
    107108
  • src/proc/thread.c

    r43114c5 r8262010  
    100100        i = (t->pri < RQ_COUNT -1) ? ++t->pri : t->pri;
    101101       
    102         cpu = the->cpu;
     102        cpu = CPU;
    103103        if (t->flags & X_WIRED) {
    104104                cpu = t->cpu;
Note: See TracChangeset for help on using the changeset viewer.