Changeset 965dc18 in mainline for kernel/genarch


Ignore:
Timestamp:
2008-12-05T19:59:03Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49093a4
Parents:
0258e67
Message:

Merge sparc branch to trunk.

Location:
kernel/genarch
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/include/fb/fb.h

    r0258e67 r965dc18  
    3939#include <synch/spinlock.h>
    4040
     41/**
     42 * Properties of the framebuffer device.
     43 */
     44typedef struct fb_properties {
     45        /** Physical address of the framebuffer device. */
     46        uintptr_t addr;
     47
     48        /**
     49         * Address where the first (top left) pixel is mapped,
     50         * relative to "addr".
     51         */
     52        unsigned int offset;   
     53
     54        /** Screen width in pixels. */
     55        unsigned int x;
     56
     57        /** Screen height in pixels. */
     58        unsigned int y;
     59
     60        /** Bytes per one scanline. */
     61        unsigned int scan;
     62
     63        /** Color model. */
     64        unsigned int visual;
     65} fb_properties_t;
     66
    4167SPINLOCK_EXTERN(fb_lock);
    42 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual);
     68void fb_init(fb_properties_t *props);
    4369
    4470#endif
  • kernel/genarch/include/fb/visuals.h

    r0258e67 r965dc18  
    4545
    4646#define VISUAL_BGR_0_8_8_8      6
     47#define VISUAL_SB1500_PALETTE   7
    4748
    4849#endif
  • kernel/genarch/include/ofw/ofw_tree.h

    r0258e67 r965dc18  
    173173extern ofw_tree_node_t *ofw_tree_find_peer_by_device_type(ofw_tree_node_t *,
    174174    const char *);
     175extern ofw_tree_node_t *ofw_tree_find_peer_by_name(ofw_tree_node_t *node,
     176    const char *name);
    175177extern ofw_tree_node_t *ofw_tree_find_node_by_handle(ofw_tree_node_t *,
    176178    uint32_t);
  • kernel/genarch/src/fb/fb.c

    r0258e67 r965dc18  
    190190        *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 |
    191191            BLUE(rgb, 3);
     192}
     193
     194static void sb1500rgb_byte8(void *dst, int rgb)
     195{
     196        if (RED(rgb, 1) && GREEN(rgb, 1) && BLUE(rgb, 1))
     197                *((uint8_t *) dst) = 255;
     198        else if (RED(rgb, 1) && GREEN(rgb, 1))
     199                *((uint8_t *) dst) = 150;
     200        else if (GREEN(rgb, 1) && BLUE(rgb, 1))
     201                *((uint8_t *) dst) = 47;
     202        else if (RED(rgb, 1) && BLUE(rgb, 1))
     203                *((uint8_t *) dst) = 48;
     204        else if (RED(rgb, 1))
     205                *((uint8_t *) dst) = 32;
     206        else if (GREEN(rgb, 1))
     207                *((uint8_t *) dst) = 47;
     208        else if (BLUE(rgb, 1))
     209                *((uint8_t *) dst) = 2;
     210        else
     211                *((uint8_t *) dst) = 1;
    192212}
    193213
     
    437457/** Initialize framebuffer as a chardev output device
    438458 *
    439  * @param addr   Physical address of the framebuffer
    440  * @param x      Screen width in pixels
    441  * @param y      Screen height in pixels
    442  * @param scan   Bytes per one scanline
    443  * @param visual Color model
    444  *
    445  */
    446 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan,
    447     unsigned int visual)
    448 {
    449         switch (visual) {
     459 * @param props         Properties of the framebuffer device.
     460 */
     461void fb_init(fb_properties_t *props)
     462{
     463        switch (props->visual) {
    450464        case VISUAL_INDIRECT_8:
    451465                rgb2scr = rgb_byte8;
     
    453467                pixelbytes = 1;
    454468                break;
     469        case VISUAL_SB1500_PALETTE:
     470                rgb2scr = sb1500rgb_byte8;
     471                scr2rgb = byte8_rgb;
     472                pixelbytes = 1;
     473                break;
    455474        case VISUAL_RGB_5_5_5:
    456475                rgb2scr = rgb_byte555;
     
    487506        }
    488507       
    489         unsigned int fbsize = scan * y;
     508        unsigned int fbsize = props->scan * props->y + props->offset;
    490509       
    491510        /* Map the framebuffer */
    492         fbaddress = (uint8_t *) hw_map((uintptr_t) addr, fbsize);
    493        
    494         xres = x;
    495         yres = y;
    496         scanline = scan;
    497        
    498         rows = y / FONT_SCANLINES;
    499         columns = x / COL_WIDTH;
    500 
    501         fb_parea.pbase = (uintptr_t) addr;
     511        fbaddress = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize);
     512        fbaddress += props->offset;
     513       
     514        xres = props->x;
     515        yres = props->y;
     516        scanline = props->scan;
     517       
     518        rows = props->y / FONT_SCANLINES;
     519        columns = props->x / COL_WIDTH;
     520
     521        fb_parea.pbase = (uintptr_t) props->addr;
    502522        fb_parea.vbase = (uintptr_t) fbaddress;
    503523        fb_parea.frames = SIZE2FRAMES(fbsize);
     
    509529        sysinfo_set_item_val("fb.width", NULL, xres);
    510530        sysinfo_set_item_val("fb.height", NULL, yres);
    511         sysinfo_set_item_val("fb.scanline", NULL, scan);
    512         sysinfo_set_item_val("fb.visual", NULL, visual);
    513         sysinfo_set_item_val("fb.address.physical", NULL, addr);
     531        sysinfo_set_item_val("fb.scanline", NULL, props->scan);
     532        sysinfo_set_item_val("fb.visual", NULL, props->visual);
     533        sysinfo_set_item_val("fb.address.physical", NULL, props->addr);
    514534        sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors);
    515535
     
    525545        if (!blankline)
    526546                panic("Failed to allocate blank line for framebuffer.");
     547        unsigned int x, y;
    527548        for (y = 0; y < FONT_SCANLINES; y++)
    528549                for (x = 0; x < xres; x++)
  • kernel/genarch/src/ofw/ofw_tree.c

    r0258e67 r965dc18  
    5555/** Get OpenFirmware node property.
    5656 *
    57  * @param node Node in which to lookup the property.
    58  * @param name Name of the property.
    59  *
    60  * @return Pointer to the property structure or NULL if no such property.
    61  */
    62 ofw_tree_property_t *ofw_tree_getprop(const ofw_tree_node_t *node, const char *name)
     57 * @param node          Node in which to lookup the property.
     58 * @param name          Name of the property.
     59 *
     60 * @return              Pointer to the property structure or NULL if no such
     61 *                      property.
     62 */
     63ofw_tree_property_t *
     64ofw_tree_getprop(const ofw_tree_node_t *node, const char *name)
    6365{
    6466        unsigned int i;
     
    7476/** Return value of the 'name' property.
    7577 *
    76  * @param node Node of interest.
    77  *
    78  * @return Value of the 'name' property belonging to the node.
     78 * @param node          Node of interest.
     79 *
     80 * @return              Value of the 'name' property belonging to the node.
    7981 */
    8082const char *ofw_tree_node_name(const ofw_tree_node_t *node)
     
    9496/** Lookup child of given name.
    9597 *
    96  * @param node Node whose child is being looked up.
    97  * @param name Name of the child being looked up.
    98  *
    99  * @return NULL if there is no such child or pointer to the matching child node.
     98 * @param node          Node whose child is being looked up.
     99 * @param name          Name of the child being looked up.
     100 *
     101 * @return              NULL if there is no such child or pointer to the
     102 *                      matching child node.
    100103 */
    101104ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node, const char *name)
     
    128131/** Lookup first child of given device type.
    129132 *
    130  * @param node Node whose child is being looked up.
    131  * @param name Device type of the child being looked up.
    132  *
    133  * @return NULL if there is no such child or pointer to the matching child node.
    134  */
    135 ofw_tree_node_t *ofw_tree_find_child_by_device_type(ofw_tree_node_t *node, const char *name)
     133 * @param node          Node whose child is being looked up.
     134 * @param name          Device type of the child being looked up.
     135 *
     136 * @return              NULL if there is no such child or pointer to the
     137 *                      matching child node.
     138 */
     139ofw_tree_node_t *
     140ofw_tree_find_child_by_device_type(ofw_tree_node_t *node, const char *name)
    136141{
    137142        ofw_tree_node_t *cur;
     
    154159 * are looked up iteratively to avoid stack overflow.
    155160 *
    156  * @param root Root of the searched subtree.
    157  * @param handle OpenFirmware handle.
    158  *
    159  * @return NULL if there is no such node or pointer to the matching node.
    160  */
    161 ofw_tree_node_t *ofw_tree_find_node_by_handle(ofw_tree_node_t *root, uint32_t handle)
     161 * @param root          Root of the searched subtree.
     162 * @param handle        OpenFirmware handle.
     163 *
     164 * @return              NULL if there is no such node or pointer to the matching
     165 *                      node.
     166 */
     167ofw_tree_node_t *
     168ofw_tree_find_node_by_handle(ofw_tree_node_t *root, uint32_t handle)
    162169{
    163170        ofw_tree_node_t *cur;
     
    181188/** Lookup first peer of given device type.
    182189 *
    183  * @param node Node whose peer is being looked up.
    184  * @param name Device type of the child being looked up.
    185  *
    186  * @return NULL if there is no such child or pointer to the matching child node.
    187  */
    188 ofw_tree_node_t *ofw_tree_find_peer_by_device_type(ofw_tree_node_t *node, const char *name)
     190 * @param node          Node whose peer is being looked up.
     191 * @param name          Device type of the child being looked up.
     192 *
     193 * @return              NULL if there is no such child or pointer to the
     194 *                      matching child node.
     195 */
     196ofw_tree_node_t *
     197ofw_tree_find_peer_by_device_type(ofw_tree_node_t *node, const char *name)
    189198{
    190199        ofw_tree_node_t *cur;
     
    203212
    204213
     214/** Lookup first peer of given name.
     215 *
     216 * @param node          Node whose peer is being looked up.
     217 * @param name          Name of the child being looked up.
     218 *
     219 * @return              NULL if there is no such peer or pointer to the matching
     220 *                      peer node.
     221 */
     222ofw_tree_node_t *
     223ofw_tree_find_peer_by_name(ofw_tree_node_t *node, const char *name)
     224{
     225        ofw_tree_node_t *cur;
     226        ofw_tree_property_t *prop;
     227       
     228        for (cur = node->peer; cur; cur = cur->peer) {
     229                prop = ofw_tree_getprop(cur, "name");
     230                if (!prop || !prop->value)
     231                        continue;
     232                if (strcmp(prop->value, name) == 0)
     233                        return cur;
     234        }
     235                       
     236        return NULL;
     237}
     238
    205239/** Lookup OpenFirmware node by its path.
    206240 *
    207  * @param path Path to the node.
    208  *
    209  * @return NULL if there is no such node or pointer to the leaf node.
     241 * @param path          Path to the node.
     242 *
     243 * @return              NULL if there is no such node or pointer to the leaf
     244 *                      node.
    210245 */
    211246ofw_tree_node_t *ofw_tree_lookup(const char *path)
    212247{
    213         char buf[NAME_BUF_LEN+1];
     248        char buf[NAME_BUF_LEN + 1];
    214249        ofw_tree_node_t *node = ofw_root;
    215250        index_t i, j;
     
    237272 * iteratively in order to avoid stack overflow.
    238273 *
    239  * @param node Root of the subtree.
    240  * @param path Current path, NULL for the very root of the entire tree.
     274 * @param node          Root of the subtree.
     275 * @param path          Current path, NULL for the very root of the entire tree.
    241276 */
    242277static void ofw_tree_node_print(const ofw_tree_node_t *node, const char *path)
Note: See TracChangeset for help on using the changeset viewer.