Changeset e507afa in mainline


Ignore:
Timestamp:
2005-11-14T19:39:26Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
abb79e84
Parents:
35667f8
Message:

For now, each architecture must use its own -O switch (-O2 doesn't work for ia64, -O3 doesn't work for mips32).

New mips32 atomic_add() function.

Cleanup.

Files:
22 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r35667f8 re507afa  
    4848
    4949DEFS = -DARCH=$(ARCH) -DRELEASE=\"$(RELEASE)\" "-DNAME=\"$(NAME)\""
    50 CFLAGS = -fno-builtin -fomit-frame-pointer -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -Igeneric/include/
     50CFLAGS = -fno-builtin -fomit-frame-pointer -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -nostdlib -nostdinc -Igeneric/include/
    5151LFLAGS = -M
    5252AFLAGS =
  • Makefile.config

    r35667f8 re507afa  
    3737
    3838CONFIG_USERSPACE = n
    39 #CONFIG_TEST =
     39CONFIG_TEST =
    4040#CONFIG_TEST = synch/rwlock1
    4141#CONFIG_TEST = synch/rwlock2
    4242#CONFIG_TEST = synch/rwlock3
    4343#CONFIG_TEST = synch/rwlock4
    44 CONFIG_TEST = synch/rwlock5
     44#CONFIG_TEST = synch/rwlock5
    4545#CONFIG_TEST = synch/semaphore1
    4646#CONFIG_TEST = synch/semaphore2
  • arch/amd64/Makefile.inc

    r35667f8 re507afa  
    4343endif
    4444
    45 CFLAGS += -fno-unwind-tables -m64 -mcmodel=kernel -mno-red-zone
     45CFLAGS += -fno-unwind-tables -m64 -mcmodel=kernel -mno-red-zone -O3
    4646DEFS += -D_CPU=${CPU}
    4747
  • arch/ia32/Makefile.inc

    r35667f8 re507afa  
    4343endif
    4444
     45CFLAGS += -O3
    4546DEFS += -D_CPU=${CPU}
    4647
  • arch/ia64/Makefile.inc

    r35667f8 re507afa  
    3939#
    4040
    41 CFLAGS += -mconstant-gp -fno-unwind-tables
     41CFLAGS += -mconstant-gp -fno-unwind-tables -minline-int-divide-min-latency -O3
    4242LFLAGS += -EL
    4343AFLAGS += -mconstant-gp
  • arch/mips32/Makefile.inc

    r35667f8 re507afa  
    4242
    4343KERNEL_LOAD_ADDRESS = 0x80100000
    44 CFLAGS += -mno-abicalls -G 0 -fno-zero-initialized-in-bss
     44CFLAGS += -mno-abicalls -G 0 -fno-zero-initialized-in-bss -O2
    4545DEFS += -DMACHINE=${MACHINE} -DKERNEL_LOAD_ADDRESS=${KERNEL_LOAD_ADDRESS}
    4646
  • arch/mips32/include/atomic.h

    r35667f8 re507afa  
    3232#include <arch/types.h>
    3333
    34 #define atomic_inc(x)   (a_add(x,1))
    35 #define atomic_dec(x)   (a_sub(x,1))
     34#define atomic_inc(x)   ((void) atomic_add(x, 1))
     35#define atomic_dec(x)   ((void) atomic_add(x, -1))
    3636
    37 #define atomic_inc_pre(x) (a_add(x,1)-1)
    38 #define atomic_dec_pre(x) (a_sub(x,1)+1)
     37#define atomic_inc_pre(x) (atomic_add(x, 1) - 1)
     38#define atomic_dec_pre(x) (atomic_add(x, -1) + 1)
    3939
    40 #define atomic_inc_post(x) (a_add(x,1))
    41 #define atomic_dec_post(x) (a_sub(x,1))
     40#define atomic_inc_post(x) atomic_add(x, 1)
     41#define atomic_dec_post(x) atomic_add(x, -1)
    4242
    4343
    4444typedef volatile __u32 atomic_t;
    4545
    46 /*
    47  * Atomic addition
     46/* Atomic addition of immediate value.
    4847 *
    49  * This case is harder, and we have to use the special LL and SC operations
    50  * to achieve atomicity. The instructions are similar to LW (load) and SW
    51  * (store), except that the LL (load-linked) instruction loads the address
    52  * of the variable to a special register and if another process writes to
    53  * the same location, the SC (store-conditional) instruction fails.
    54  
    55  Returns (*val)+i
    56  
     48 * @param val Memory location to which will be the immediate value added.
     49 * @param i Signed immediate that will be added to *val.
     50 *
     51 * @return Value after addition.
    5752 */
    58 static inline atomic_t a_add(atomic_t *val, int i)
     53static inline atomic_t atomic_add(atomic_t *val, int i)
    5954{
    60         atomic_t tmp, tmp2;
     55        atomic_t tmp, v;
    6156
    62         asm volatile (
    63                 "       .set    push\n"
    64                 "       .set    noreorder\n"
    65                 "       nop\n"
     57        __asm__ volatile (
    6658                "1:\n"
    67                 "       ll      %0, %1\n"
    68                 "       addu    %0, %0, %3\n"
    69                 "       move    %2, %0\n"
    70                 "       sc      %0, %1\n"
    71                 "       beq     %0, 0x0, 1b\n"
    72                 "       move    %0, %2\n"
    73                 "       .set    pop\n"
    74                 : "=&r" (tmp), "=o" (*val), "=r" (tmp2)
    75                 : "r" (i)
     59                "       ll %0, %1\n"
     60                "       addiu %0, %0, %3\n"     /* same as addi, but never traps on overflow */
     61                "       move %2, %0\n"
     62                "       sc %0, %1\n"
     63                "       beq %0, %4, 1b\n"       /* if the atomic operation failed, try again */
     64                /*      nop     */              /* nop is inserted automatically by compiler */
     65                : "=r" (tmp), "=m" (*val), "=r" (v)
     66                : "i" (i), "i" (0)
    7667                );
    77         return tmp;
    78 }
    7968
    80 
    81 /*
    82  * Atomic subtraction
    83  *
    84  * Implemented in the same manner as a_add, except we substract the value.
    85 
    86  Returns (*val)-i
    87 
    88  */
    89 static inline atomic_t a_sub(atomic_t *val, int i)
    90 
    91 {
    92         atomic_t tmp, tmp2;
    93 
    94         asm volatile (
    95                 "       .set    push\n"
    96                 "       .set    noreorder\n"
    97                 "       nop\n"
    98                 "1:\n"
    99                 "       ll      %0, %1\n"
    100                 "       subu    %0, %0, %3\n"
    101                 "       move    %2, %0\n"
    102                 "       sc      %0, %1\n"
    103                 "       beq     %0, 0x0, 1b\n"
    104                 "       move    %0, %2\n"
    105                 "       .set    pop\n"
    106                 : "=&r" (tmp), "=o" (*val), "=r" (tmp2)
    107                 : "r" (i)
    108                 );
    109         return tmp;
     69        return v;
    11070}
    11171
  • arch/mips32/include/cpu.h

    r35667f8 re507afa  
    3030#define __mips32_CPU_H__
    3131
     32#include <arch/types.h>
     33
    3234struct cpu_arch {
    33         int imp_num;
    34         int rev_num;
     35        __u32 imp_num;
     36        __u32 rev_num;
    3537};
    3638       
  • arch/mips32/src/interrupt.c

    r35667f8 re507afa  
    115115                                case 5: /* IRQ3 */
    116116                                case 6: /* IRQ4 */
     117                                default:
    117118                                        print_regdump(pstate);
    118119                                        panic("unhandled interrupt %d\n", i);
  • arch/ppc32/Makefile.inc

    r35667f8 re507afa  
    3939#
    4040
     41CFLAGS += -O3
    4142LFLAGS += -no-check-sections -N
    4243
  • arch/sparc64/Makefile.inc

    r35667f8 re507afa  
    3939#
    4040
    41 CFLAGS += -mcpu=ultrasparc -m64
     41CFLAGS += -mcpu=ultrasparc -m64 -O3
    4242LFLAGS += -no-check-sections -N
    4343
  • generic/include/arch.h

    r35667f8 re507afa  
    5353 */
    5454struct the {
    55         int preemption_disabled;        /**< Preemption disabled counter. */
     55        count_t preemption_disabled;    /**< Preemption disabled counter. */
    5656        thread_t *thread;               /**< Current thread. */
    5757        task_t *task;                   /**< Current task. */
  • generic/include/config.h

    r35667f8 re507afa  
    3636#define STACK_SIZE              PAGE_SIZE
    3737
    38 #define CONFIG_MEMORY_SIZE      8*1024*1024
    39 #define CONFIG_HEAP_SIZE        300*1024
     38#define CONFIG_MEMORY_SIZE      (8*1024*1024)
     39#define CONFIG_HEAP_SIZE        (300*1024)
    4040#define CONFIG_STACK_SIZE       STACK_SIZE
    4141
  • generic/include/cpu.h

    r35667f8 re507afa  
    4646        context_t saved_context;
    4747
    48         volatile int nrdy;
     48        volatile count_t nrdy;
    4949        runq_t rq[RQ_COUNT];
    50         volatile int needs_relink;
     50        volatile count_t needs_relink;
    5151
    5252        spinlock_t timeoutlock;
  • generic/include/proc/scheduler.h

    r35667f8 re507afa  
    3939#define NEEDS_RELINK_MAX        (HZ)
    4040
     41/** Scheduler run queue structure. */
    4142struct runq {
    4243        spinlock_t lock;
    4344        link_t rq_head;         /**< List of ready threads. */
    44         int n;                  /**< Number of threads in rq_ready. */
     45        count_t n;              /**< Number of threads in rq_ready. */
    4546};
    4647
     
    5253extern void kcpulb(void *arg);
    5354
     55extern void before_thread_runs(void);
     56
    5457/*
    5558 * To be defined by architectures:
    5659 */
    5760 
    58 extern void before_thread_runs(void);
    5961extern void before_thread_runs_arch(void);
    6062
  • generic/include/synch/rwlock.h

    r35667f8 re507afa  
    4444        spinlock_t lock;
    4545        mutex_t exclusive;      /**< Mutex for writers, readers can bypass it if readers_in is positive. */
    46         int readers_in;         /**< Number of readers in critical section. */
     46        count_t readers_in;     /**< Number of readers in critical section. */
    4747};
    4848
  • generic/include/typedefs.h

    r35667f8 re507afa  
    4040
    4141typedef struct config config_t;
    42 typedef struct cpu_private_data cpu_private_data_t;
    4342typedef struct cpu_info cpu_info_t;
    4443
  • generic/src/proc/scheduler.c

    r35667f8 re507afa  
    5151atomic_t nrdy;
    5252
    53 
    5453/** Take actions before new thread runs
    5554 *
     
    117116 *
    118117 */
    119 static struct thread *find_best_thread(void)
     118static thread_t *find_best_thread(void)
    120119{
    121120        thread_t *t;
  • test/fpu/fpu1/test.c

    r35667f8 re507afa  
    4646static inline double sqrt(double x) { double v; __asm__ ("fsqrt\n" : "=t" (v) : "0" (x)); return v; }
    4747
    48 static volatile int threads_ok;
     48static atomic_t threads_ok;
    4949static waitq_t can_start;
    5050
  • test/fpu/mips1/test.c

    r35667f8 re507afa  
    4242#define ATTEMPTS        5
    4343
    44 static volatile int threads_ok;
     44static atomic_t threads_ok;
    4545static waitq_t can_start;
    4646
  • test/fpu/sse1/test.c

    r35667f8 re507afa  
    4242#define ATTEMPTS        5
    4343
    44 static volatile int threads_ok;
     44static atomic_t threads_ok;
    4545static waitq_t can_start;
    4646
  • test/synch/rwlock5/test.c

    r35667f8 re507afa  
    7676{
    7777        int i, j, k;
    78         int readers, writers;
     78        count_t readers, writers;
    7979       
    8080        printf("Read/write locks test #5\n");
Note: See TracChangeset for help on using the changeset viewer.