Changeset 9a5b556 in mainline for kernel


Ignore:
Timestamp:
2006-09-12T13:03:55Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6eabb6e6
Parents:
7bb6b06
Message:

sparc64 work:

  • find a CPU node and read its clock_frequency attribute
  • implement asm_delay_loop()
  • set TICK_COMPARE register according to processor frequency
  • small improvements at random places

OpenFirmware work:

  • two new functions for walking the device tree

Generic boot loader work:

  • added basic string functions

Usual pile of indentation and formatting fixes.

Location:
kernel
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/drivers/it.c

    r7bb6b06 r9a5b556  
    2727 */
    2828
    29  /** @addtogroup ia64   
     29/** @addtogroup ia64   
    3030 * @{
    3131 */
     
    7777        eoi_write(EOI);
    7878       
    79         m=itm_read();
     79        m = itm_read();
    8080       
    81         while(1)
    82         {
    83        
    84                 c=itc_read();
    85                 c+=IT_SERVICE_CLOCKS;
     81        while (1) {
     82                c = itc_read();
     83                c += IT_SERVICE_CLOCKS;
    8684
    87                 m+=IT_DELTA;
    88                 if(m-c<0)
    89                 {
     85                m += IT_DELTA;
     86                if (m-c<0)
    9087                        CPU->missed_clock_ticks++;
    91                 }
    92                 else break;
     88                else
     89                        break;
    9390        }
    9491       
     
    9693        srlz_d();                               /* propagate changes */
    9794       
    98        
    99        
    10095        clock();
    10196        poll_keyboard();
    10297}
    10398
    104  /** @}
     99/** @}
    105100 */
    106 
  • kernel/arch/mips32/include/asm.h

    r7bb6b06 r9a5b556  
    6767                          uintptr_t entry);
    6868
     69extern ipl_t interrupts_disable(void);
     70extern ipl_t interrupts_enable(void);
     71extern void interrupts_restore(ipl_t ipl);
     72extern ipl_t interrupts_read(void);
     73
    6974#endif
    7075
  • kernel/arch/mips32/src/interrupt.c

    r7bb6b06 r9a5b556  
    2727 */
    2828
    29  /** @addtogroup mips32interrupt
     29/** @addtogroup mips32interrupt
    3030 * @{
    3131 */
     
    142142}
    143143
    144  /** @}
     144/** @}
    145145 */
    146146
  • kernel/arch/sparc64/include/asm.h

    r7bb6b06 r9a5b556  
    3636#define KERN_sparc64_ASM_H_
    3737
     38#include <arch.h>
    3839#include <typedefs.h>
    3940#include <arch/types.h>
    4041#include <arch/register.h>
    4142#include <config.h>
     43#include <time/clock.h>
    4244
    4345/** Read Processor State register.
     
    336338extern void cpu_halt(void);
    337339extern void cpu_sleep(void);
    338 extern void asm_delay_loop(uint32_t t);
     340extern void asm_delay_loop(const uint32_t usec);
    339341
    340342extern uint64_t read_from_ag_g7(void);
  • kernel/arch/sparc64/include/boot/boot.h

    r7bb6b06 r9a5b556  
    8484
    8585typedef struct {
     86        uint32_t clock_frequency;
     87} processor_t;
     88
     89typedef struct {
    8690        taskmap_t taskmap;
    8791        memmap_t memmap;
    8892        screen_t screen;
    8993        keyboard_t keyboard;
     94        processor_t processor;
    9095} bootinfo_t;
    9196
  • kernel/arch/sparc64/include/cpu.h

    r7bb6b06 r9a5b556  
    5353struct cpu_arch {
    5454        ver_reg_t ver;
     55        uint32_t clock_frequency;
    5556};
    5657       
  • kernel/arch/sparc64/include/drivers/tick.h

    r7bb6b06 r9a5b556  
    3838#include <typedefs.h>
    3939
    40 #define TICK_DELTA        500000
    41 
    4240extern void tick_init(void);
    4341extern void tick_interrupt(int n, istate_t *istate);
  • kernel/arch/sparc64/src/cpu/cpu.c

    r7bb6b06 r9a5b556  
    3333 */
    3434
     35#include <arch/asm.h>
    3536#include <cpu.h>
    3637#include <arch.h>
    3738#include <arch/register.h>
    38 #include <arch/asm.h>
    3939#include <print.h>
     40#include <arch/boot/boot.h>
    4041
    4142void cpu_arch_init(void)
    4243{
     44        CPU->arch.clock_frequency = bootinfo.processor.clock_frequency;
    4345}
    4446
     
    9496        }
    9597
    96         printf("cpu%d: manuf=%s, impl=%s, mask=%d\n", CPU->id, manuf, impl, CPU->arch.ver.mask);
     98        printf("cpu%d: manuf=%s, impl=%s, mask=%d (%dMHz)\n",
     99                CPU->id, manuf, impl, CPU->arch.ver.mask, CPU->arch.clock_frequency/1000000);
    97100}
    98101
  • kernel/arch/sparc64/src/drivers/tick.c

    r7bb6b06 r9a5b556  
    3737#include <arch/asm.h>
    3838#include <arch/register.h>
     39#include <typedefs.h>
     40#include <arch/cpu.h>
     41#include <arch/boot/boot.h>
     42#include <time/clock.h>
     43#include <arch.h>
    3944#include <debug.h>
    40 #include <time/clock.h>
    41 #include <typedefs.h>
     45
     46#define TICK_RESTART_TIME       50      /* Worst case estimate. */
    4247
    4348/** Initialize tick interrupt. */
     
    4853        interrupt_register(14, "tick_int", tick_interrupt);
    4954        compare.int_dis = false;
    50         compare.tick_cmpr = TICK_DELTA;
     55        compare.tick_cmpr = bootinfo.processor.clock_frequency/HZ;
    5156        tick_compare_write(compare.value);
    5257        tick_write(0);
     
    6166{
    6267        softint_reg_t softint, clear;
     68        uint64_t next, compare, start, stop;
    6369       
    6470        softint.value = softint_read();
     
    8490         * Restart counter.
    8591         */
    86         tick_write(0);
     92        compare = CPU->arch.clock_frequency/HZ;
     93        start = tick_read();
     94        next = start - compare;
     95        while (next >= compare - TICK_RESTART_TIME) {
     96                next -= compare;
     97                CPU->missed_clock_ticks++;
     98        }
     99        stop = tick_read();
     100        tick_write(next + (stop - start));
    87101       
    88102        clock();
  • kernel/arch/sparc64/src/dummy.s

    r7bb6b06 r9a5b556  
    2929.text
    3030
    31 .global asm_delay_loop
    3231.global cpu_sleep
    3332.global fpu_context_restore
     
    3938.global dummy
    4039
    41 asm_delay_loop:
    4240cpu_sleep:
    4341fpu_context_restore:
  • kernel/arch/sparc64/src/sparc64.c

    r7bb6b06 r9a5b556  
    4343#include <arch/boot/boot.h>
    4444#include <arch/arch.h>
     45#include <arch/asm.h>
    4546#include <arch/mm/page.h>
    4647#include <arch/stack.h>
     
    9091}
    9192
     93/** Calibrate delay loop.
     94 *
     95 * On sparc64, we implement delay() by waiting for the TICK register to
     96 * reach a pre-computed value, as opposed to performing some pre-computed
     97 * amount of instructions of known duration. We set the delay_loop_const
     98 * to 1 in order to neutralize the multiplication done by delay().
     99 */
    92100void calibrate_delay_loop(void)
    93101{
     102        CPU->delay_loop_const = 1;
     103}
     104
     105/** Wait several microseconds.
     106 *
     107 * We assume that interrupts are already disabled.
     108 *
     109 * @param t Microseconds to wait.
     110 */
     111void asm_delay_loop(const uint32_t usec)
     112{
     113        uint64_t stop = tick_read() + (uint64_t) usec * (uint64_t) CPU->arch.clock_frequency / 1000000;
     114
     115        while (tick_read() < stop)
     116                ;
    94117}
    95118
  • kernel/arch/sparc64/src/start.S

    r7bb6b06 r9a5b556  
    6161         */
    6262
    63         flushw                          ! flush all but the active register window
    64         wrpr %g0, 0, %tl                ! TL = 0, primary context register is used
    65 
    66         ! Disable interrupts and disable 32-bit address masking.
    67         rdpr %pstate, %g1
    68         and %g1, ~(PSTATE_AM_BIT|PSTATE_IE_BIT), %g1
    69         wrpr %g1, 0, %pstate
    70 
    71         wrpr %g0, 0, %pil               ! intialize %pil
     63        flushw                                  ! flush all but the active register window
     64
     65        wrpr %g0, 0, %tl                        ! TL = 0, primary context register is used
     66
     67        wrpr %g0, PSTATE_PRIV_BIT, %pstate      ! Disable interrupts and disable 32-bit address masking.
     68
     69        wrpr %g0, 0, %pil                       ! intialize %pil
    7270
    7371        /*
  • kernel/generic/include/arch.h

    r7bb6b06 r9a5b556  
    3333 */
    3434
    35 #ifndef __ARCH_H__
    36 #define __ARCH_H__
     35#ifndef KERN_ARCH_H_
     36#define KERN_ARCH_H_
    3737
    3838#include <arch/types.h>
     
    8080extern void calibrate_delay_loop(void);
    8181
    82 extern ipl_t interrupts_disable(void);
    83 extern ipl_t interrupts_enable(void);
    84 extern void interrupts_restore(ipl_t ipl);
    85 extern ipl_t interrupts_read(void);
    86 
    8782#endif
    8883
  • kernel/generic/include/cpu.h

    r7bb6b06 r9a5b556  
    3333 */
    3434
    35 #ifndef __CPU_H__
    36 #define __CPU_H__
     35#ifndef KERN_CPU_H_
     36#define KERN_CPU_H_
    3737
    3838#include <arch/cpu.h>
  • kernel/generic/include/time/clock.h

    r7bb6b06 r9a5b556  
    3333 */
    3434
    35 #ifndef __CLOCK_H__
    36 #define __CLOCK_H__
     35#ifndef KERN_CLOCK_H_
     36#define KERN_CLOCK_H_
    3737
    3838#define HZ              100
  • kernel/generic/include/time/delay.h

    r7bb6b06 r9a5b556  
    3333 */
    3434
    35 #ifndef __DELAY_H__
    36 #define __DELAY_H__
     35#ifndef KERN_DELAY_H_
     36#define KERN_DELAY_H_
    3737
    3838#include <arch/types.h>
  • kernel/generic/include/time/timeout.h

    r7bb6b06 r9a5b556  
    3333 */
    3434
    35 #ifndef __TIMEOUT_H__
    36 #define __TIMEOUT_H__
     35#ifndef KERN_TIMEOUT_H_
     36#define KERN_TIMEOUT_H_
    3737
    3838#include <arch/types.h>
  • kernel/generic/include/typedefs.h

    r7bb6b06 r9a5b556  
    3333 */
    3434
    35 #ifndef __TYPEDEFS_H__
    36 #define __TYPEDEFS_H__
     35#ifndef KERN_TYPEDEFS_H_
     36#define KERN_TYPEDEFS_H_
    3737
    3838#define false 0
  • kernel/generic/src/cpu/cpu.c

    r7bb6b06 r9a5b556  
    110110}
    111111
    112  /** @}
     112/** @}
    113113 */
    114114
Note: See TracChangeset for help on using the changeset viewer.