Changeset 0ffa3ef5 in mainline


Ignore:
Timestamp:
2006-07-10T20:57:30Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
11675207
Parents:
7f1c620
Message:

Sync OpenFirmware functionality with boot.
Random cleanup.

Files:
22 edited

Legend:

Unmodified
Added
Removed
  • arch/sparc64/include/asm.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_ASM_H__
    36 #define __sparc64_ASM_H__
     35#ifndef KERN_sparc64_ASM_H_
     36#define KERN_sparc64_ASM_H_
    3737
    3838#include <typedefs.h>
     
    305305}
    306306
    307 
    308 
    309307void cpu_halt(void);
    310308void cpu_sleep(void);
     
    313311#endif
    314312
    315  /** @}
    316  */
    317 
     313/** @}
     314 */
  • arch/sparc64/include/atomic.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    100100#endif
    101101
    102  /** @}
     102/** @}
    103103 */
    104 
  • arch/sparc64/include/barrier.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    7070#endif
    7171
    72  /** @}
     72/** @}
    7373 */
    74 
  • arch/sparc64/include/console.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_CONSOLE_H__
    36 #define __sparc64_CONSOLE_H__
     35#ifndef KERN_sparc64_CONSOLE_H_
     36#define KERN_sparc64_CONSOLE_H_
    3737
    38 extern void kofwinput(void *arg);
    3938extern void kkbdpoll(void *arg);
    4039extern void ofw_sparc64_console_init(void);
     
    4342#endif
    4443
    45  /** @}
     44/** @}
    4645 */
    47 
  • arch/sparc64/include/drivers/fb.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_FB_H__
    36 #define __sparc64_FB_H__
     35#ifndef KERN_sparc64_FB_H_
     36#define KERN_sparc64_FB_H_
    3737
    3838#define FB_PHYS_ADDRESS         0x1c901000000ULL
     
    4545#endif
    4646
    47  /** @}
     47/** @}
    4848 */
    49 
  • arch/sparc64/include/drivers/i8042.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_I8042_H__
    36 #define __sparc64_I8042_H__
     35#ifndef KERN_sparc64_I8042_H_
     36#define KERN_sparc64_I8042_H_
    3737
    3838#include <arch/types.h>
     
    7272#endif
    7373
    74  /** @}
     74/** @}
    7575 */
    76 
  • arch/sparc64/include/elf.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    4242#endif
    4343
    44  /** @}
     44/** @}
    4545 */
    46 
  • arch/sparc64/include/register.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_REGISTER_H__
    36 #define __sparc64_REGISTER_H__
     35#ifndef KERN_sparc64_REGISTER_H_
     36#define KERN_sparc64_REGISTER_H_
     37
     38#ifdef __ASM__
     39#define PSTATE_IE_BIT   2
     40#define PSTATE_AM_BIT   8
     41#else
    3742
    3843#include <arch/types.h>
     
    107112#endif
    108113
    109  /** @}
     114#endif
     115
     116/** @}
    110117 */
    111 
  • arch/sparc64/include/stack.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_STACK_H__
    36 #define __sparc64_STACK_H__
     35#ifndef KERN_sparc64_STACK_H_
     36#define KERN_sparc64_STACK_H_
    3737
    3838#define STACK_ITEM_SIZE                 8
     
    5353#endif
    5454
    55  /** @}
     55/** @}
    5656 */
    57 
  • arch/sparc64/include/trap/interrupt.h

    r7f1c620 r0ffa3ef5  
    7979/** @}
    8080 */
    81 
  • arch/sparc64/src/asm.S

    r7f1c620 r0ffa3ef5  
    2727#
    2828
     29#include <arch/stack.h>
     30#include <arch/register.h>
     31
    2932.text
    3033
     
    3538.global memcpy_to_uspace_failover_address
    3639.global memsetb
     40
    3741
    3842memcpy:
     
    5256        nop
    5357
     58.global ofw
     59ofw:
     60        save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
     61        set ofw_cif, %l0
     62        ldx [%l0], %l0
     63
     64        rdpr  %pstate, %l1
     65        and  %l1, ~PSTATE_AM_BIT, %l2
     66        wrpr  %l2, 0, %pstate
     67           
     68        jmpl %l0, %o7
     69        mov %i0, %o0
     70       
     71        wrpr  %l1, 0, %pstate
     72
     73        ret
     74        restore %o0, 0, %o0
  • arch/sparc64/src/console.c

    r7f1c620 r0ffa3ef5  
    5252
    5353static void ofw_sparc64_putchar(chardev_t *d, const char ch);
    54 static char ofw_sparc64_getchar(chardev_t *d);
    55 static void ofw_sparc64_suspend(chardev_t *d);
    56 static void ofw_sparc64_resume(chardev_t *d);
    57 
    58 mutex_t canwork;
    5954
    6055static volatile int ofw_console_active;
     
    6358static chardev_operations_t ofw_sparc64_console_ops = {
    6459        .write = ofw_sparc64_putchar,
    65         .read = ofw_sparc64_getchar,
    66         .resume = ofw_sparc64_resume,
    67         .suspend = ofw_sparc64_suspend
    6860};
    6961
     
    7264{
    7365        chardev_initialize("ofw_sparc64_console", &ofw_sparc64_console, &ofw_sparc64_console_ops);
    74         stdin = &ofw_sparc64_console;
     66        stdin = NULL;
    7567        stdout = &ofw_sparc64_console;
    76         mutex_initialize(&canwork);
    7768        ofw_console_active = 1;
    7869}
     
    9586void ofw_sparc64_putchar(chardev_t *d, const char ch)
    9687{
    97         pstate_reg_t pstate;
    98 
    99         /*
    100          * 32-bit OpenFirmware depends on PSTATE.AM bit set.
    101          */     
    102         pstate.value = pstate_read();
    103         pstate.am = true;
    104         pstate_write(pstate.value);
    105 
    10688        if (ch == '\n')
    10789                ofw_putchar('\r');
    10890        ofw_putchar(ch);
    109        
    110         pstate.am = false;
    111         pstate_write(pstate.value);
    112 }
    113 
    114 /** Read one character using OpenFirmware.
    115  *
    116  * The call is non-blocking.
    117  *
    118  * @param d Character device (ignored).
    119  * @return Character read or zero if no character was read.
    120  */
    121 char ofw_sparc64_getchar(chardev_t *d)
    122 {
    123         char ch;
    124         pstate_reg_t pstate;
    125 
    126         /*
    127          * 32-bit OpenFirmware depends on PSTATE.AM bit set.
    128          */     
    129         pstate.value = pstate_read();
    130         pstate.am = true;
    131         pstate_write(pstate.value);
    132 
    133         ch = ofw_getchar();
    134        
    135         pstate.am = false;
    136         pstate_write(pstate.value);
    137        
    138         return ch;
    139 }
    140 
    141 void ofw_sparc64_suspend(chardev_t *d)
    142 {
    143         mutex_lock(&canwork);
    144 }
    145 
    146 void ofw_sparc64_resume(chardev_t *d)
    147 {
    148         mutex_unlock(&canwork);
    149 }
    150 
    151 /** Kernel thread for pushing characters read from OFW to input buffer.
    152  *
    153  * @param arg Ignored.
    154  */
    155 void kofwinput(void *arg)
    156 {
    157 
    158         while (ofw_console_active) {
    159                 char ch = 0;
    160                
    161                 mutex_lock(&canwork);
    162                 mutex_unlock(&canwork);
    163                
    164                 ch = ofw_sparc64_getchar(NULL);
    165                 if (ch) {
    166                         if (ch == '\r')
    167                                 ch = '\n';
    168                         chardev_push_character(&ofw_sparc64_console, ch);
    169                 }
    170                 thread_usleep(KEYBOARD_POLL_PAUSE);
    171         }
    17291}
    17392
  • arch/sparc64/src/drivers/i8042.c

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64       
     29/** @addtogroup sparc64
    3030 * @{
    3131 */
     
    4646}
    4747
    48  /** @}
     48/** @}
    4949 */
    50 
  • arch/sparc64/src/mm/frame.c

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64mm     
     29/** @addtogroup sparc64mm       
    3030 * @{
    3131 */
     
    5252}
    5353
    54  /** @}
     54/** @}
    5555 */
    56 
  • arch/sparc64/src/mm/memory_init.c

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64mm     
     29/** @addtogroup sparc64mm       
    3030 * @{
    3131 */
     
    4242}
    4343
    44  /** @}
     44/** @}
    4545 */
    4646
  • arch/sparc64/src/proc/scheduler.c

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup sparc64proc
     29/** @addtogroup sparc64proc
    3030 * @{
    3131 */
     
    8080}
    8181
    82  /** @}
     82/** @}
    8383 */
    84 
  • arch/sparc64/src/sparc64.c

    r7f1c620 r0ffa3ef5  
    4141#include <console/console.h>
    4242
     43#include <print.h>
     44#include <genarch/ofw/ofw.h>
     45#include <arch/asm.h>
     46#include <arch/register.h>
    4347void arch_pre_mm_init(void)
    4448{
    4549        interrupts_disable();
    4650        ofw_sparc64_console_init();
     51
    4752        trap_init();
    4853        tick_init();
     
    6166{
    6267        thread_t *t;
    63 
    64         /*
    65          * Create thread that reads characters from OFW's input.
    66          */
    67         t = thread_create(kofwinput, NULL, TASK, 0, "kofwinput");
    68         if (!t)
    69                 panic("cannot create kofwinput\n");
    70         thread_ready(t);
    7168
    7269        /*
  • arch/sparc64/src/start.S

    r7f1c620 r0ffa3ef5  
    2828
    2929#include <arch/boot/boot.h>
     30#include <arch/register.h>
    3031
    3132.register %g2, #scratch
     
    3839/*
    3940 * Here is where the kernel is passed control.
    40  * The code must be position independent until
    41  * the kernel relocates itself to its VMA.
    4241 */
    4342
     
    4645        flushw                          ! flush all but the active register window
    4746
    48         set ofw, %l0
     47        rdpr %pstate, %l0
     48        and %l0, ~PSTATE_AM_BIT, %l0
     49        wrpr %l0, 0, %pstate
     50
     51        set ofw_cif, %l0
    4952
    5053        call ofw_init
  • genarch/include/ofw/memory_init.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup genarch       
     29/** @addtogroup genarch
    3030 * @{
    3131 */
     
    4444#endif
    4545
    46  /** @}
     46/** @}
    4747 */
    4848
  • genarch/include/ofw/ofw.h

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup genarch       
     29/** @addtogroup genarch
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __OFW_H__
    36 #define __OFW_H__
     35#ifndef KERN_OFW_H_
     36#define KERN_OFW_H_
    3737
    3838#include <arch/types.h>
    3939
    40 #define MAX_OFW_ARGS    10
     40#define MAX_OFW_ARGS    12
    4141
    4242typedef unative_t ofw_arg_t;
    43 typedef int ihandle;
    44 typedef int phandle;
     43typedef unsigned int ihandle;
     44typedef unsigned int phandle;
    4545
    4646/** OpenFirmware command structure
     
    4848 */
    4949typedef struct {
    50         const char *service;          /**< Command name */
    51         unative_t nargs;               /**< Number of in arguments */
    52         unative_t nret;                /**< Number of out arguments */
    53         ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments */
     50        const char *service;            /**< Command name */
     51        unative_t nargs;                /**< Number of in arguments */
     52        unative_t nret;                 /**< Number of out arguments */
     53        ofw_arg_t args[MAX_OFW_ARGS];   /**< Buffer for in and out arguments */
    5454} ofw_args_t;
    5555
    56 typedef void (*ofw_entry)(ofw_args_t *);
    57 
    58 extern ofw_entry ofw;
     56extern int ofw(ofw_args_t *);           /**< OpenFirmware Client Interface entry point. */
    5957
    6058extern void ofw_init(void);
    6159extern void ofw_done(void);
    62 extern unative_t ofw_call(const char *service, const int nargs, const int nret, ...);
     60extern ofw_arg_t ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...);
    6361extern void ofw_putchar(const char ch);
    64 extern char ofw_getchar(void);
    6562extern phandle ofw_find_device(const char *name);
    66 extern int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen);
     63extern int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen);
     64extern void *ofw_translate(const void *addr);
    6765extern void *ofw_claim(const void *addr, const int size, const int align);
    6866
    6967#endif
    7068
    71  /** @}
     69/** @}
    7270 */
    73 
  • genarch/src/ofw/memory_init.c

    r7f1c620 r0ffa3ef5  
    2727 */
    2828
    29  /** @addtogroup genarch       
     29/** @addtogroup genarch
    3030 * @{
    3131 */
     
    9494}
    9595
    96  /** @}
     96/** @}
    9797 */
    98 
  • genarch/src/ofw/ofw.c

    r7f1c620 r0ffa3ef5  
    3939#include <arch/types.h>
    4040
    41 ofw_entry ofw;
     41uintptr_t ofw_cif;      /**< OpenFirmware Client Interface address. */
    4242
    4343phandle ofw_chosen;
    44 ihandle ofw_stdin;
    4544ihandle ofw_stdout;
     45ihandle ofw_mmu;
    4646
    4747void ofw_init(void)
     
    5151                ofw_done();
    5252       
    53         if (ofw_get_property(ofw_chosen, "stdin",  &ofw_stdin, sizeof(ofw_stdin)) <= 0)
    54                 ofw_stdin = 0;
    55                
    5653        if (ofw_get_property(ofw_chosen, "stdout",  &ofw_stdout, sizeof(ofw_stdout)) <= 0)
    5754                ofw_stdout = 0;
     55
     56        if (ofw_get_property(ofw_chosen, "mmu",  &ofw_mmu, sizeof(ofw_mmu)) <= 0)
     57                ofw_mmu = 0;
    5858}
    5959
    6060void ofw_done(void)
    6161{
    62         (void) ofw_call("exit", 0, 0);
     62        (void) ofw_call("exit", 0, 1, NULL);
    6363        cpu_halt();
    6464}
    6565
    66 unative_t ofw_call(const char *service, const int nargs, const int nret, ...)
     66/** Perform a call to OpenFirmware client interface.
     67 *
     68 * @param service String identifying the service requested.
     69 * @param nargs Number of input arguments.
     70 * @param nret Number of output arguments. This includes the return value.
     71 * @param rets Buffer for output arguments or NULL. The buffer must accomodate nret - 1 items.
     72 *
     73 * @return Return value returned by the client interface.
     74 */
     75ofw_arg_t ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...)
    6776{
    6877        va_list list;
     
    7483        args.nret = nret;
    7584       
    76         va_start(list, nret);
     85        va_start(list, rets);
    7786        for (i = 0; i < nargs; i++)
    7887                args.args[i] = va_arg(list, ofw_arg_t);
     
    8291                args.args[i + nargs] = 0;
    8392       
    84         ofw(&args);
    85        
     93        (void) ofw(&args);
     94
     95        for (i = 1; i < nret; i++)
     96                rets[i - 1] = args.args[i + nargs];
     97
    8698        return args.args[nargs];
    8799}
     
    92104                return;
    93105       
    94         (void) ofw_call("write", 3, 1, ofw_stdout, &ch, 1);
    95 }
    96 
    97 /** Read character from OFW's input.
    98  *
    99  * This call is non-blocking.
    100  *
    101  * @return 0 if no character was read, character read otherwise.
    102  */
    103 char ofw_getchar(void)
    104 {
    105         char ch;
    106 
    107         if (ofw_stdin == 0)
    108                 return 0;
    109        
    110         if (ofw_call("read", 3, 1, ofw_stdin, &ch, 1) == 1)
    111                 return ch;
    112         else
    113                 return 0;
     106        (void) ofw_call("write", 3, 1, NULL, ofw_stdout, &ch, 1);
    114107}
    115108
    116109phandle ofw_find_device(const char *name)
    117110{
    118         return (phandle) ofw_call("finddevice", 1, 1, name);
     111        return (phandle) ofw_call("finddevice", 1, 1, NULL, name);
    119112}
    120113
    121 int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen)
     114int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
    122115{
    123         return (int) ofw_call("getprop", 4, 1, device, name, buf, buflen);
     116        return (int) ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
     117}
     118
     119/** Translate virtual address to physical address using OpenFirmware.
     120 *
     121 * Use this function only when OpenFirmware is in charge.
     122 *
     123 * @param virt Virtual address.
     124 * @return NULL on failure or physical address on success.
     125 */
     126void *ofw_translate(const void *virt)
     127{
     128        ofw_arg_t result[4];
     129        int shift;
     130       
     131        if (!ofw_mmu)
     132                return NULL;
     133       
     134        if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu, virt) != 0)
     135                return NULL;
     136
     137        if (result[0] != -1)
     138                return NULL;
     139                                                               
     140        if (sizeof(unative_t) == 8)
     141                shift = 32;
     142        else
     143                shift = 0;
     144       
     145        return (void *) ((result[2]<<shift)|result[3]);
    124146}
    125147
    126148void *ofw_claim(const void *addr, const int size, const int align)
    127149{
    128         return (void *) ofw_call("claim", 3, 1, addr, size, align);
     150        return (void *) ofw_call("claim", 3, 1, NULL, addr, size, align);
    129151}
    130152
Note: See TracChangeset for help on using the changeset viewer.