Changeset 7ce9284 in mainline


Ignore:
Timestamp:
2005-08-30T17:41:19Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b45aa23
Parents:
10caad0
Message:

Dump implementation of THREAD, TASK and CPU.
Implement preemption-safe versions of THREAD, TASK and CPU using THE.
Get rid of CPU_ID_ARCH on all architectures.
Get rid of write_dr0() and read_dr0() on IA-32.
Get rid of cpu_private_data and cpu_private_data_t.

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/cpu.h

    r10caad0 r7ce9284  
    3636#include <arch/asm.h>
    3737
    38 #ifdef __SMP__
    39 #define CPU_ID_ARCH     (read_dr0())
    40 #else
    41 #define CPU_ID_ARCH     (0)
    42 #endif
    43 
    4438struct cpu_arch {
    4539        int vendor;
  • arch/ia32/include/asm.h

    r10caad0 r7ce9284  
    8484static inline __u32 read_cr3(void) { __u32 v; __asm__ volatile ("movl %%cr3,%0" : "=r" (v)); return v; }
    8585
    86 /** Write DR0
    87  *
    88  * Write value to DR0.
    89  *
    90  * @param v Value to be written.
    91  */
    92 static inline void write_dr0(__u32 v) { __asm__ volatile ("movl %0,%%dr0\n" : : "r" (v)); }
    93 
    94 /** Read DR0
    95  *
    96  * Return value in DR0
    97  *
    98  * @return Value read.
    99  */
    100 static inline __u32 read_dr0(void) { __u32 v; __asm__ volatile ("movl %%dr0,%0" : "=r" (v)); return v; }
    101 
    10286/** Set priority level low
    10387 *
  • arch/ia32/include/cpu.h

    r10caad0 r7ce9284  
    3434#include <arch/asm.h>
    3535
    36 #ifdef __SMP__
    37 #define CPU_ID_ARCH     (read_dr0())
    38 #else
    39 #define CPU_ID_ARCH     (0)
    40 #endif
    41 
    4236struct cpu_arch {
    4337        int vendor;
  • arch/ia32/src/ia32.c

    r10caad0 r7ce9284  
    5252        pm_init();
    5353
    54         write_dr0(config.cpu_active - 1);
    55 
    5654        if (config.cpu_active == 1) {
    5755                bios_init();
  • arch/ia64/include/cpu.h

    r10caad0 r7ce9284  
    3232#include <typedefs.h>
    3333
    34 #define CPU_ID_ARCH     0
    35 
    3634struct cpu_arch {
    3735};
  • arch/mips/include/cpu.h

    r10caad0 r7ce9284  
    3030#define __mips_CPU_H__
    3131
    32 #define CPU_ID_ARCH     0
    33 
    3432struct cpu_arch {
    3533        int imp_num;
  • arch/ppc/include/cpu.h

    r10caad0 r7ce9284  
    3232#include <typedefs.h>
    3333
    34 #define CPU_ID_ARCH     0
    35 
    3634struct cpu_arch {
    3735};
  • include/arch.h

    r10caad0 r7ce9284  
    4040#include <proc/task.h>
    4141
    42 /*
    43  * NOTE:
    44  * CPU, THREAD and TASK are not preemption-safe.
    45  * Provisions must be made to prevent preemption prior
    46  * to using these macros. Simple cpu_priority_high()
    47  * call will suffice.
    48  */
    49 #define CPU             (&cpus[CPU_ID_ARCH])
    50 #define THREAD          (cpu_private_data[CPU_ID_ARCH].thread)
    51 #define TASK            (cpu_private_data[CPU_ID_ARCH].task)
     42#define CPU             THE->cpu
     43#define THREAD          THE->thread
     44#define TASK            THE->task
    5245
    5346/*
  • include/cpu.h

    r10caad0 r7ce9284  
    7272};
    7373
    74 /*
    75  * read/write by associated CPU
    76  * read only by other CPUs
    77  */
    78 struct cpu_private_data {
    79         thread_t *thread;
    80         task_t *task;
    81 };
    82 
    83 extern cpu_private_data_t *cpu_private_data;
    8474extern cpu_t *cpus;
    8575
  • src/Makefile.config

    r10caad0 r7ce9284  
    2121
    2222# Uncomment if you want to run in the test mode
    23 TEST=__TEST__
     23#TEST=__TEST__
    2424
    2525TEST_FILE=test.c
     
    3434#TEST_DIR=synch/semaphore2/
    3535#TEST_DIR=fpu/fpu1
    36 TEST_DIR=print/print1
     36#TEST_DIR=print/print1
  • src/cpu/cpu.c

    r10caad0 r7ce9284  
    4040#include <list.h>
    4141
    42 
    43 cpu_private_data_t *cpu_private_data;
    4442cpu_t *cpus;
    45 
    4643
    4744/** Initialize CPUs
     
    5653        if (config.cpu_active == 1) {
    5754        #endif /* __SMP__ */
    58                 cpu_private_data = (cpu_private_data_t *) malloc(sizeof(cpu_private_data_t) * config.cpu_count);
    59                 if (!cpu_private_data)
    60                         panic("malloc/cpu_private_data");
    61 
    6255                cpus = (cpu_t *) malloc(sizeof(cpu_t) * config.cpu_count);
    6356                if (!cpus)
     
    6558
    6659                /* initialize everything */
    67                 memsetb((__address) cpu_private_data, sizeof(cpu_private_data_t) * config.cpu_count, 0);
    6860                memsetb((__address) cpus, sizeof(cpu_t) * config.cpu_count, 0);
    6961
    7062                for (i=0; i < config.cpu_count; i++) {
    71                         cpus[i].stack = (__u8 *) malloc(CPU_STACK_SIZE);
     63                        cpus[i].stack = (__u8 *) frame_alloc(FRAME_KA | FRAME_PANIC);
    7264                        if (!cpus[i].stack)
    7365                                panic("malloc/cpus[%d].stack\n", i);
     
    8779        }
    8880        #endif /* __SMP__ */
     81
     82        CPU = &cpus[config.cpu_active-1];
    8983       
    9084        CPU->active = 1;
  • src/main/main.c

    r10caad0 r7ce9284  
    180180        t = thread_create(kinit, NULL, k, 0);
    181181        if (!t) panic("can't create kinit thread\n");
    182 
    183182        thread_ready(t);
    184183
     
    211210        config.cpu_active++;
    212211
     212        /*
     213         * The THE structure is well defined because ctx.sp is used as stack.
     214         */
     215        the_initialize(THE);
     216
    213217        arch_pre_mm_init();
    214218        frame_init();
     
    222226        l_apic_debug();
    223227
     228        the_copy(THE, (the_t *) CPU->stack);
    224229
    225230        /*
  • src/proc/scheduler.c

    r10caad0 r7ce9284  
    364364        priority = THREAD->pri;
    365365        spinlock_unlock(&THREAD->lock);
    366        
     366
    367367        relink_rq(priority);           
    368368
Note: See TracChangeset for help on using the changeset viewer.