Changeset 2e672fd in mainline


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

Some 32-bit vs. 64-bit fixes.

Make the call to OpenFirmware client interface architecture dependent.
For instance and contrary to my previous experience, the sparc64 version of
'translate' method would not work reliably unless the Address Mask bit in the
PSTATE register is cleared during duration of the call.

sparc64 and ppc32 OpenFirmware seem to differ in details, for example, the above
mentioned method 'translate' signals success by setting the first return value
to -1 on sparc64 while on ppc32 the value is/stays (???) zero.

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • arch/ppc32/loader/boot.S

    r822b64e r2e672fd  
    3434
    3535start:
    36         lis r4, ofw@ha
    37         addi r4, r4, ofw@l
     36        lis r4, ofw_cif@ha
     37        addi r4, r4, ofw_cif@l
    3838        stw r5, 0(r4)
    3939       
  • arch/ppc32/loader/main.c

    r822b64e r2e672fd  
    157157       
    158158        printf("\nBooting the kernel...\n");
    159         jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa, bootinfo.screen.addr, bootinfo.screen.scanline);
     159        jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa, (void *) bootinfo.screen.addr, bootinfo.screen.scanline);
    160160}
  • arch/ppc32/loader/ofw.c

    r822b64e r2e672fd  
    3030#include <printf.h>
    3131
     32typedef int (* ofw_entry_t)(ofw_args_t *args);
     33
     34int ofw(ofw_args_t *args)
     35{
     36        return ((ofw_entry_t) ofw_cif)(args);
     37}
     38
    3239void write(const char *str, const int len)
    3340{
     
    4956        if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
    5057                return false;
    51         keyboard->addr = (void *) macio.addr.addr_lo;
     58        keyboard->addr = macio.addr.addr_lo;
    5259        keyboard->size = macio.size_lo;
    5360
    5461        return true;
    5562}
     63
     64int ofw_translate_failed(ofw_arg_t flag)
     65{
     66        return 0;
     67}
  • arch/ppc64/loader/boot.S

    r822b64e r2e672fd  
    3434
    3535start:
    36         lis r4, ofw@ha
    37         addi r4, r4, ofw@l
     36        lis r4, ofw_cif@ha
     37        addi r4, r4, ofw_cif@l
    3838        stw r5, 0(r4)
    3939       
  • arch/ppc64/loader/ofw.c

    r822b64e r2e672fd  
    3030#include <printf.h>
    3131
     32typedef int (* ofw_entry_t)(ofw_args_t *args);
     33
     34int ofw(ofw_args_t *args)
     35{
     36        return ((ofw_entry_t) ofw_cif)(args);
     37}
     38
    3239void write(const char *str, const int len)
    3340{
     
    5461        return true;
    5562}
     63
     64int ofw_translate_failed(ofw_arg_t flag)
     65{
     66        return 0;
     67}
  • arch/sparc64/loader/asm.S

    r822b64e r2e672fd  
    2626# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727#
     28
     29#define STACK_WINDOW_SAVE_AREA_SIZE     (16*8)
     30
     31#define PSTATE_AM_BIT   8
    2832
    2933.text
     
    9599
    96100jump_to_kernel:
    97         set ofw, %l0
     101        set ofw_cif, %l0
    98102        jmp %o0                         ! jump to kernel
    99103        ldx [%l0], %o4                  ! pass OpenFirmware address in %o4
     104
     105.global ofw
     106ofw:
     107        save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
     108        set ofw_cif, %l0
     109        ldx [%l0], %l0
     110
     111        rdpr  %pstate, %l1
     112        and  %l1, ~PSTATE_AM_BIT, %l2
     113        wrpr  %l2, 0, %pstate
     114   
     115        jmpl %l0, %o7
     116        mov %i0, %o0
     117
     118        wrpr %l1, 0, %pstate
     119
     120        ret
     121        restore %o0, 0, %o0
  • arch/sparc64/loader/boot.S

    r822b64e r2e672fd  
    2929#define INITIAL_STACK 0x0
    3030
     31#define PSTATE_IE_BIT   2
     32
    3133.register %g2, #scratch
    3234.register %g3, #scratch
     
    5355        flushw
    5456
     57        /*
     58         * Disable interrupts.
     59         */
     60        rdpr %pstate, %g2
     61        and %g2, ~PSTATE_IE_BIT, %g2    ! mask the Interrupt Enable bit
     62        wrpr %g2, 0, %pstate
     63
    5564        # TODO: set initial stack
    5665
    57         set ofw, %l0
     66        set ofw_cif, %l0
    5867 
    5968        call init               ! initialize OpenFirmware
  • arch/sparc64/loader/main.c

    r822b64e r2e672fd  
    5252                printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
    5353
    54         screen_t scr;
    55        
    56         ofw_screen(&scr);
    57         printf("\n%P: fb, %dx%dx%d\n", ofw_translate(scr.addr), scr.width, scr.height, scr.bpp);
    58 
    59        
    6054        printf("\nCopying components\n");
    6155        unsigned int top = 0;
  • arch/sparc64/loader/ofw.c

    r822b64e r2e672fd  
    4040        }
    4141}
     42
     43int ofw_translate_failed(ofw_arg_t flag)
     44{
     45        return flag != -1;
     46}
  • genarch/ofw.c

    r822b64e r2e672fd  
    3232#include <types.h>
    3333
    34 #define MAX_OFW_ARGS            10
    35 
    36 /** OpenFirmware command structure
    37  *
    38  */
    39 typedef struct {
    40         const char *service;          /**< Command name */
    41         unsigned long nargs;          /**< Number of in arguments */
    42         unsigned long nret;           /**< Number of out arguments */
    43         ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments */
    44 } ofw_args_t;
    45 
    46 typedef void (*ofw_entry)(ofw_args_t *);
    47 
    48 ofw_entry ofw;
     34uintptr_t ofw_cif;
    4935
    5036phandle ofw_chosen;
     
    7359                args.args[i + nargs] = 0;
    7460       
    75         ofw(&args);
    76        
     61        (void) ofw(&args);
     62
    7763        for (i = 1; i < nret; i++)
    7864                rets[i - 1] = args.args[i + nargs];
    79        
     65
    8066        return args.args[nargs];
    8167}
     
    176162                halt();
    177163        }
     164
     165        if (ofw_translate_failed(result[0]))
     166                return NULL;
    178167
    179168        if (sizeof(unative_t) == 8)
     
    182171                shift = 0;
    183172               
    184         return (void *) (((result[2]&0xffffffff)<<shift)|((result[3])&0xffffffff));
    185 }
    186 
     173        return (void *) ((result[2]<<shift)|result[3]);
     174}
     175
     176void *ofw_claim(const void *virt, const int len)
     177{
     178        ofw_arg_t retaddr;
     179        int shift;
     180
     181        if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len, virt) != 0) {
     182                puts("Error: MMU method claim() failed, halting.\n");
     183                halt();
     184        }
     185
     186        return (void *) retaddr;
     187}
    187188
    188189int ofw_map(const void *phys, const void *virt, const int size, const int mode)
  • genarch/ofw.h

    r822b64e r2e672fd  
    3737#define MEMMAP_MAX_RECORDS      32
    3838
     39#define MAX_OFW_ARGS            12
     40
     41typedef unsigned long ofw_arg_t;
     42typedef unsigned int ihandle;
     43typedef unsigned int phandle;
     44
     45/** OpenFirmware command structure
     46 *
     47 */
     48typedef struct {
     49        const char *service;            /**< Command name */
     50        unsigned long nargs;            /**< Number of in arguments */
     51        unsigned long nret;             /**< Number of out arguments */
     52        ofw_arg_t args[MAX_OFW_ARGS];   /**< List of arguments */
     53} ofw_args_t;
     54
    3955typedef struct {
    4056        void *start;
     
    4965
    5066typedef struct {
    51         void *addr;
     67        uint32_t addr;
    5268        unsigned int width;
    5369        unsigned int height;
     
    5773
    5874typedef struct {
    59         void *addr;
     75        uint32_t addr;
    6076        unsigned int size;
    6177} keyboard_t;
     
    7389} pci_reg_t;
    7490
    75 typedef unsigned long ofw_arg_t;
    76 typedef unsigned int ihandle;
    77 typedef unsigned int phandle;
     91extern uintptr_t ofw_cif;
    7892
    7993extern phandle ofw_aliases;
     
    8599extern phandle ofw_find_device(const char *name);
    86100
     101extern int ofw(ofw_args_t *arg);
    87102extern void *ofw_translate(const void *virt);
     103extern int ofw_translate_failed(ofw_arg_t flag);
     104extern void *ofw_claim(const void *virt, const int len);
    88105extern int ofw_map(const void *phys, const void *virt, const int size, const int mode);
    89106extern int ofw_memmap(memmap_t *map);
Note: See TracChangeset for help on using the changeset viewer.