Subversion Repositories HelenOS-historic

Rev

Rev 186 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 186 Rev 191
Line 27... Line 27...
27
 */
27
 */
28
 
28
 
29
#include <arch/drivers/ofw.h>
29
#include <arch/drivers/ofw.h>
30
#include <stdarg.h>
30
#include <stdarg.h>
31
 
31
 
32
ihandle ofw_chosen;
-
 
33
ihandle ofw_stdout;
-
 
34
ofw_entry ofw;
32
ofw_entry ofw;
35
 
33
 
-
 
34
phandle ofw_chosen;
-
 
35
ihandle ofw_stdout;
-
 
36
 
36
void ofw_init(void)
37
void ofw_init(void)
37
{
38
{
38
    ofw_chosen = ofw_call("finddevice", 1, 1, "/chosen");
39
    ofw_chosen = ofw_find_device("/chosen");
39
    if (ofw_chosen == -1)
40
    if (ofw_chosen == -1)
40
        ofw_done();
41
        ofw_done();
41
   
42
   
42
    if (ofw_call("getprop", 4, 1, ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
43
    if (ofw_call("getprop", 4, 1, ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
43
        ofw_stdout = 0;
44
        ofw_stdout = 0;
Line 50... Line 51...
50
}
51
}
51
 
52
 
52
int ofw_call(const char *service, const int nargs, const int nret, ...)
53
int ofw_call(const char *service, const int nargs, const int nret, ...)
53
{
54
{
54
    va_list list;
55
    va_list list;
55
    struct ofw_args_t args;
56
    ofw_args_t args;
56
    int i;
57
    int i;
57
   
58
   
58
    args.service = service;
59
    args.service = service;
59
    args.nargs = nargs;
60
    args.nargs = nargs;
60
    args.nret = nret;
61
    args.nret = nret;
Line 75... Line 76...
75
void ofw_putchar(const char ch)
76
void ofw_putchar(const char ch)
76
{
77
{
77
    if (ofw_stdout == 0)
78
    if (ofw_stdout == 0)
78
        return;
79
        return;
79
   
80
   
80
    ofw_call("write", 3, 1, ofw_stdout, ch, 1);
81
    ofw_call("write", 3, 1, ofw_stdout, &ch, 1);
-
 
82
}
-
 
83
 
-
 
84
phandle ofw_find_device(const char *name)
-
 
85
{
-
 
86
    return ofw_call("finddevice", 1, 1, name);
-
 
87
}
-
 
88
 
-
 
89
int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen)
-
 
90
{
-
 
91
    return ofw_call("getprop", 4, 1, device, name, buf, buflen);
81
}
92
}
82
 
93
 
83
void putchar(const char ch)
94
void putchar(const char ch)
84
{
95
{
85
    ofw_putchar(ch);
96
    ofw_putchar(ch);