Subversion Repositories HelenOS

Rev

Rev 1897 | Rev 1986 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1897 Rev 1898
1
/*
1
/*
2
 * Copyright (C) 2006 Jakub Jermar
2
 * Copyright (C) 2006 Jakub Jermar
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup sparc64
29
/** @addtogroup sparc64
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#include <arch/drivers/scr.h>
35
#include <arch/drivers/scr.h>
36
#include <genarch/ofw/ofw_tree.h>
36
#include <genarch/ofw/ofw_tree.h>
37
#include <genarch/fb/fb.h>
37
#include <genarch/fb/fb.h>
38
#include <arch/types.h>
38
#include <arch/types.h>
39
#include <typedefs.h>
39
#include <typedefs.h>
40
#include <func.h>
40
#include <func.h>
41
#include <align.h>
41
#include <align.h>
42
#include <print.h>
42
#include <print.h>
43
 
43
 
-
 
44
#define FFB_REG_24BPP   7
-
 
45
 
44
scr_type_t scr_type = SCR_UNKNOWN;
46
scr_type_t scr_type = SCR_UNKNOWN;
45
 
47
 
46
/** Initialize screen.
48
/** Initialize screen.
47
 *
49
 *
48
 * Traverse OpenFirmware device tree in order to find necessary
50
 * Traverse OpenFirmware device tree in order to find necessary
49
 * info about the screen device.
51
 * info about the screen device.
50
 *
52
 *
51
 * @param node Screen device node.
53
 * @param node Screen device node.
52
 */
54
 */
53
void scr_init(ofw_tree_node_t *node)
55
void scr_init(ofw_tree_node_t *node)
54
{
56
{
55
    ofw_tree_property_t *prop;
57
    ofw_tree_property_t *prop;
56
    const char *name;
58
    const char *name;
57
   
59
   
58
    name = ofw_tree_node_name(node);
60
    name = ofw_tree_node_name(node);
59
   
61
   
60
    if (strcmp(name, "SUNW,m64B") == 0)
62
    if (strcmp(name, "SUNW,m64B") == 0)
61
        scr_type = SCR_ATYFB;
63
        scr_type = SCR_ATYFB;
62
    else if (strcmp(name, "SUNW,ffb") == 0)
64
    else if (strcmp(name, "SUNW,ffb") == 0)
63
        scr_type = SCR_FFB;
65
        scr_type = SCR_FFB;
64
   
66
   
65
    if (scr_type == SCR_UNKNOWN) {
67
    if (scr_type == SCR_UNKNOWN) {
66
        printf("Unknown keyboard device.\n");
68
        printf("Unknown keyboard device.\n");
67
        return;
69
        return;
68
    }
70
    }
69
   
71
   
70
    uintptr_t fb_addr;
72
    uintptr_t fb_addr;
71
    uint32_t fb_width = 0;
73
    uint32_t fb_width = 0;
72
    uint32_t fb_height = 0;
74
    uint32_t fb_height = 0;
73
    uint32_t fb_depth = 0;
75
    uint32_t fb_depth = 0;
74
    uint32_t fb_linebytes = 0;
76
    uint32_t fb_linebytes = 0;
75
    uint32_t fb_scanline = 0;
77
    uint32_t fb_scanline = 0;
76
 
78
 
77
    prop = ofw_tree_getprop(node, "width");
79
    prop = ofw_tree_getprop(node, "width");
78
    if (prop && prop->value)
80
    if (prop && prop->value)
79
        fb_width = *((uint32_t *) prop->value);
81
        fb_width = *((uint32_t *) prop->value);
80
 
82
 
81
    prop = ofw_tree_getprop(node, "height");
83
    prop = ofw_tree_getprop(node, "height");
82
    if (prop && prop->value)
84
    if (prop && prop->value)
83
        fb_height = *((uint32_t *) prop->value);
85
        fb_height = *((uint32_t *) prop->value);
84
 
86
 
85
    prop = ofw_tree_getprop(node, "depth");
87
    prop = ofw_tree_getprop(node, "depth");
86
    if (prop && prop->value)
88
    if (prop && prop->value)
87
        fb_depth = *((uint32_t *) prop->value);
89
        fb_depth = *((uint32_t *) prop->value);
88
 
90
 
89
    prop = ofw_tree_getprop(node, "linebytes");
91
    prop = ofw_tree_getprop(node, "linebytes");
90
    if (prop && prop->value)
92
    if (prop && prop->value)
91
        fb_linebytes = *((uint32_t *) prop->value);
93
        fb_linebytes = *((uint32_t *) prop->value);
92
 
94
 
93
    prop = ofw_tree_getprop(node, "reg");
95
    prop = ofw_tree_getprop(node, "reg");
94
    if (!prop)
96
    if (!prop)
95
        panic("Can't find \"reg\" property.\n");
97
        panic("Can't find \"reg\" property.\n");
96
 
98
 
97
    switch (scr_type) {
99
    switch (scr_type) {
98
    case SCR_ATYFB:
100
    case SCR_ATYFB:
99
        if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
101
        if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
100
            printf("Too few screen registers.\n");
102
            printf("Too few screen registers.\n");
101
            return;
103
            return;
102
        }
104
        }
103
   
105
   
104
        ofw_pci_reg_t *fb_reg = &((ofw_pci_reg_t *) prop->value)[1];
106
        ofw_pci_reg_t *fb_reg = &((ofw_pci_reg_t *) prop->value)[1];
105
        ofw_pci_reg_t abs_reg;
107
        ofw_pci_reg_t abs_reg;
106
       
108
       
107
        if (!ofw_pci_reg_absolutize(node, fb_reg, &abs_reg)) {
109
        if (!ofw_pci_reg_absolutize(node, fb_reg, &abs_reg)) {
108
            printf("Failed to absolutize fb register.\n");
110
            printf("Failed to absolutize fb register.\n");
109
            return;
111
            return;
110
        }
112
        }
111
   
113
   
112
        if (!ofw_pci_apply_ranges(node->parent, &abs_reg , &fb_addr)) {
114
        if (!ofw_pci_apply_ranges(node->parent, &abs_reg , &fb_addr)) {
113
            printf("Failed to determine screen address.\n");
115
            printf("Failed to determine screen address.\n");
114
            return;
116
            return;
115
        }
117
        }
116
 
118
 
117
        if (fb_depth == 24)
119
        if (fb_depth == 24)
118
            fb_scanline = fb_linebytes * 4;
120
            fb_scanline = fb_linebytes * 4;
119
        else
121
        else
120
            fb_scanline = fb_linebytes * (fb_depth >> 3);
122
            fb_scanline = fb_linebytes * (fb_depth >> 3);
121
       
123
       
122
        break;
124
        break;
123
    case SCR_FFB:
125
    case SCR_FFB:  
-
 
126
        fb_depth = 24;
-
 
127
        fb_scanline = 8192;
-
 
128
 
-
 
129
        ofw_upa_reg_t *reg = &((ofw_upa_reg_t *) prop->value)[FFB_REG_24BPP];
-
 
130
        if (!ofw_upa_apply_ranges(node->parent, reg, &fb_addr)) {
-
 
131
            printf("Failed to determine screen address.\n");
-
 
132
            return;
-
 
133
        }
-
 
134
 
-
 
135
        break;
124
    default:
136
    default:
125
        panic("Unexpected type.\n");
137
        panic("Unexpected type.\n");
126
    }
138
    }
127
 
139
 
128
    fb_init(fb_addr, fb_width, fb_height, fb_depth, fb_scanline, true);
140
    fb_init(fb_addr, fb_width, fb_height, fb_depth, fb_scanline, true);
129
}
141
}
130
 
142
 
131
/** @}
143
/** @}
132
 */
144
 */
133
 
145