Subversion Repositories HelenOS-historic

Rev

Rev 1782 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1782 Rev 1783
Line 29... Line 29...
29
#include "ofw.h"
29
#include "ofw.h"
30
#include <printf.h>
30
#include <printf.h>
31
#include <asm.h>
31
#include <asm.h>
32
#include <types.h>
32
#include <types.h>
33
 
33
 
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;
34
uintptr_t ofw_cif;
49
 
35
 
50
phandle ofw_chosen;
36
phandle ofw_chosen;
51
ihandle ofw_stdout;
37
ihandle ofw_stdout;
52
phandle ofw_root;
38
phandle ofw_root;
53
ihandle ofw_mmu;
39
ihandle ofw_mmu;
Line 70... Line 56...
70
    va_end(list);
56
    va_end(list);
71
   
57
   
72
    for (i = 0; i < nret; i++)
58
    for (i = 0; i < nret; i++)
73
        args.args[i + nargs] = 0;
59
        args.args[i + nargs] = 0;
74
   
60
   
75
    ofw(&args);
61
    (void) ofw(&args);
76
   
62
 
77
    for (i = 1; i < nret; i++)
63
    for (i = 1; i < nret; i++)
78
        rets[i - 1] = args.args[i + nargs];
64
        rets[i - 1] = args.args[i + nargs];
79
   
65
 
80
    return args.args[nargs];
66
    return args.args[nargs];
81
}
67
}
82
 
68
 
83
 
69
 
84
phandle ofw_find_device(const char *name)
70
phandle ofw_find_device(const char *name)
Line 174... Line 160...
174
    if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu, virt) != 0) {
160
    if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu, virt) != 0) {
175
        puts("Error: MMU method translate() failed, halting.\n");
161
        puts("Error: MMU method translate() failed, halting.\n");
176
        halt();
162
        halt();
177
    }
163
    }
178
 
164
 
-
 
165
    if (ofw_translate_failed(result[0]))
-
 
166
        return NULL;
-
 
167
 
179
    if (sizeof(unative_t) == 8)
168
    if (sizeof(unative_t) == 8)
180
        shift = 32;
169
        shift = 32;
181
    else
170
    else
182
        shift = 0;
171
        shift = 0;
183
       
172
       
184
    return (void *) (((result[2]&0xffffffff)<<shift)|((result[3])&0xffffffff));
173
    return (void *) ((result[2]<<shift)|result[3]);
185
}
174
}
186
 
175
 
-
 
176
void *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
}
187
 
188
 
188
int ofw_map(const void *phys, const void *virt, const int size, const int mode)
189
int ofw_map(const void *phys, const void *virt, const int size, const int mode)
189
{
190
{
190
    uintptr_t phys_hi, phys_lo;
191
    uintptr_t phys_hi, phys_lo;
191
 
192