Changeset 28ecadb in mainline for kernel/genarch


Ignore:
Timestamp:
2006-09-22T21:44:54Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5d684e4
Parents:
16529d5
Message:

Convert sparc64 to detect keyboard and determine
its physical address by walking the memory representation
of the OpenFirmware device tree.

Add bus-specific functions that know how to apply the
"ranges" property to one component of the "reg" property.
Buses supported so far include FHC, EBUS and PCI.

Location:
kernel/genarch
Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/Makefile.inc

    r16529d5 r28ecadb  
    7373endif
    7474
     75## Sun keyboard
     76ifeq ($(CONFIG_SUN_KBD),y)
     77        GENARCH_SOURCES += \
     78                genarch/src/kbd/key.c \
     79                genarch/src/kbd/scanc_sun.c
     80endif
     81
    7582## z8530 controller
    7683ifeq ($(CONFIG_Z8530),y)
    7784        GENARCH_SOURCES += \
    78                 genarch/src/kbd/z8530.c \
    79                 genarch/src/kbd/key.c \
    80                 genarch/src/kbd/scanc_sun.c
     85                genarch/src/kbd/z8530.c
    8186endif
    8287
     
    8489ifeq ($(CONFIG_NS16550),y)
    8590        GENARCH_SOURCES += \
    86                 genarch/src/kbd/ns16550.c \
    87                 genarch/src/kbd/key.c \
    88                 genarch/src/kbd/scanc_sun.c
     91                genarch/src/kbd/ns16550.c
    8992endif
    9093
     
    9396ifeq ($(CONFIG_OFW_TREE), y)
    9497        GENARCH_SOURCES += \
    95                 genarch/src/ofw/ofw_tree.c
     98                genarch/src/ofw/ofw_tree.c \
     99                genarch/src/ofw/ebus.c \
     100                genarch/src/ofw/fhc.c \
     101                genarch/src/ofw/pci.c
    96102endif
  • kernel/genarch/include/kbd/i8042.h

    r16529d5 r28ecadb  
    3636#define KERN_I8042_H_
    3737
     38#include <typedefs.h>
     39
    3840extern void i8042_init(void);
    3941extern void i8042_poll(void);
    4042extern void i8042_grab(void);
    4143extern void i8042_release(void);
     44extern char i8042_key_read(chardev_t *d);
    4245
    4346#endif
  • kernel/genarch/include/kbd/key.h

    r16529d5 r28ecadb  
    5050extern void active_read_key_pressed(uint8_t sc);
    5151
    52 extern char key_read(chardev_t *d);
    53 
    5452#endif
    5553
  • kernel/genarch/include/kbd/ns16550.h

    r16529d5 r28ecadb  
    3838#define KERN_NS16550_H_
    3939
     40#include <typedefs.h>
     41
    4042extern void ns16550_init(void);
    4143extern void ns16550_poll(void);
    4244extern void ns16550_grab(void);
    4345extern void ns16550_release(void);
     46extern char ns16550_key_read(chardev_t *d);
    4447
    4548#endif
  • kernel/genarch/include/kbd/z8530.h

    r16529d5 r28ecadb  
    4949extern void z8530_release(void);
    5050extern void z8530_interrupt(void);
     51extern char z8530_key_read(chardev_t *d);
    5152
    5253#endif
  • kernel/genarch/include/ofw/ofw_tree.h

    r16529d5 r28ecadb  
    5757};
    5858
     59/*
     60 * Definition of 'reg' and 'ranges' properties for various buses.
     61 */
     62 
     63struct ofw_fhc_reg {
     64        uint64_t addr;
     65        uint32_t size;
     66} __attribute__ ((packed));
     67typedef struct ofw_fhc_reg ofw_fhc_reg_t;
     68                       
     69struct ofw_fhc_range {
     70        uint64_t child_base;
     71        uint64_t parent_base;
     72        uint32_t size;
     73} __attribute__ ((packed));
     74typedef struct ofw_fhc_range ofw_fhc_range_t;
     75
     76struct ofw_central_reg {
     77        uint64_t addr;
     78        uint32_t size;
     79} __attribute__ ((packed));
     80typedef struct ofw_central_reg ofw_central_reg_t;
     81
     82struct ofw_central_range {
     83        uint64_t child_base;
     84        uint64_t parent_base;
     85        uint32_t size;
     86} __attribute__ ((packed));
     87typedef struct ofw_central_range ofw_central_range_t;
     88
     89struct ofw_ebus_reg {
     90        uint32_t space;
     91        uint32_t addr;
     92        uint32_t size;
     93} __attribute__ ((packed));
     94typedef struct ofw_ebus_reg ofw_ebus_reg_t;
     95
     96struct ofw_ebus_range {
     97        uint32_t child_space;
     98        uint32_t child_base;
     99        uint32_t parent_space;
     100        uint64_t parent_base;           /* group phys.mid and phys.lo together */
     101        uint32_t size;
     102} __attribute__ ((packed));
     103typedef struct ofw_ebus_range ofw_ebus_range_t;
     104
     105struct ofw_pci_reg {
     106        uint32_t space;                 /* needs to masked to obtain pure space id */
     107        uint64_t addr;                  /* group phys.mid and phys.lo together */
     108        uint64_t size;
     109} __attribute__ ((packed));
     110typedef struct ofw_pci_reg ofw_pci_reg_t;
     111
     112struct ofw_pci_range {
     113        uint32_t space;
     114        uint64_t child_base;            /* group phys.mid and phys.lo together */
     115        uint64_t parent_base;
     116        uint64_t size;
     117} __attribute__ ((packed));
     118typedef struct ofw_pci_range ofw_pci_range_t;
     119
     120struct ofw_ffb_reg {
     121} __attribute__ ((packed));
     122typedef struct ofw_ffb_reg ofw_ffb_reg_t;
     123
    59124extern void ofw_tree_init(ofw_tree_node_t *root);
    60125extern void ofw_tree_print(void);
    61126extern const char *ofw_tree_node_name(const ofw_tree_node_t *node);
    62127extern ofw_tree_node_t *ofw_tree_lookup(const char *path);
     128extern ofw_tree_property_t *ofw_tree_getprop(const ofw_tree_node_t *node, const char *name);
     129
     130extern bool ofw_fhc_apply_ranges(ofw_tree_node_t *node, ofw_fhc_reg_t *reg, uintptr_t *pa);
     131extern bool ofw_central_apply_ranges(ofw_tree_node_t *node, ofw_central_reg_t *reg, uintptr_t *pa);
     132extern bool ofw_ebus_apply_ranges(ofw_tree_node_t *node, ofw_ebus_reg_t *reg, uintptr_t *pa);
     133extern bool ofw_pci_apply_ranges(ofw_tree_node_t *node, ofw_pci_reg_t *reg, uintptr_t *pa);
     134extern bool ofw_ffb_apply_ranges(ofw_tree_node_t *node, ofw_ffb_reg_t *reg, uintptr_t *pa);
    63135
    64136#endif
  • kernel/genarch/src/kbd/i8042.c

    r16529d5 r28ecadb  
    8181static void i8042_resume(chardev_t *);
    8282
    83 chardev_t kbrd;
    8483static chardev_operations_t ops = {
    8584        .suspend = i8042_suspend,
    8685        .resume = i8042_resume,
    87         .read = key_read
     86        .read = i8042_key_read
    8887};
    8988
     
    174173}
    175174
    176 char key_read(chardev_t *d)
     175char i8042_key_read(chardev_t *d)
    177176{
    178177        char ch;       
  • kernel/genarch/src/kbd/key.c

    r16529d5 r28ecadb  
    5454#define ACTIVE_READ_BUFF_SIZE 16        /* Must be power of 2 */
    5555
     56chardev_t kbrd;
     57
    5658static uint8_t active_read_buff[ACTIVE_READ_BUFF_SIZE];
    5759
  • kernel/genarch/src/kbd/ns16550.c

    r16529d5 r28ecadb  
    6060static void ns16550_resume(chardev_t *);
    6161
    62 chardev_t kbrd;
    6362static chardev_operations_t ops = {
    6463        .suspend = ns16550_suspend,
    6564        .resume = ns16550_resume,
    66         .read = key_read
     65        .read = ns16550_key_read
    6766};
    6867
     
    119118}
    120119
    121 char key_read(chardev_t *d)
     120char ns16550_key_read(chardev_t *d)
    122121{
    123122        char ch;       
  • kernel/genarch/src/kbd/z8530.c

    r16529d5 r28ecadb  
    6363static void z8530_resume(chardev_t *);
    6464
    65 chardev_t kbrd;
    6665static chardev_operations_t ops = {
    6766        .suspend = z8530_suspend,
    6867        .resume = z8530_resume,
    69         .read = key_read
     68        .read = z8530_key_read
    7069};
    7170
     
    142141}
    143142
    144 char key_read(chardev_t *d)
     143char z8530_key_read(chardev_t *d)
    145144{
    146145        char ch;       
  • kernel/genarch/src/ofw/ofw_tree.c

    r16529d5 r28ecadb  
    5252}
    5353
     54/** Get OpenFirmware node property.
     55 *
     56 * @param node Node in which to lookup the property.
     57 * @param name Name of the property.
     58 *
     59 * @return Pointer to the property structure or NULL if no such property.
     60 */
     61ofw_tree_property_t *ofw_tree_getprop(const ofw_tree_node_t *node, const char *name)
     62{
     63        int i;
     64       
     65        for (i = 0; i < node->properties; i++) {
     66                if (strcmp(node->property[i].name, name) == 0)
     67                        return &node->property[i];
     68        }
     69
     70        return NULL;
     71}
     72
    5473/** Return value of the 'name' property.
    5574 *
     
    6079const char *ofw_tree_node_name(const ofw_tree_node_t *node)
    6180{
    62         int i;
     81        ofw_tree_property_t *prop;
    6382       
    64         for (i = 0; i < node->properties; i++) {
    65                 if (strncmp(node->property[i].name, "name", strlen("name")) == 0) {
    66                         if (node->property[i].size < 2)
    67                                 panic("Invalid name property.\n");
    68                         return node->property[i].value;
    69                 }
    70         }
     83        prop = ofw_tree_getprop(node, "name");
     84        if (!prop)
     85                panic("Node without name property.\n");
     86               
     87        if (prop->size < 2)
     88                panic("Invalid name property.\n");
    7189       
    72         panic("Node without name property.\n");
     90        return prop->value;
    7391}
    7492
     
    7694 *
    7795 * @param node Node whose child is being looked up.
    78  * @param da_name Disambigued name of the child being looked up.
     96 * @param name Name of the child being looked up.
    7997 *
    8098 * @return NULL if there is no such child or pointer to the matching child node.
    8199 */
    82 static ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node, const char *da_name)
     100static ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node, const char *name)
    83101{
    84102        ofw_tree_node_t *cur;
    85103       
     104        /*
     105         * Try to find the disambigued name.
     106         */
    86107        for (cur = node->child; cur; cur = cur->peer) {
    87                 if (strncmp(cur->da_name, da_name, strlen(da_name)) == 0)
     108                if (strcmp(cur->da_name, name) == 0)
    88109                        return cur;
    89110        }
    90111       
     112        /*
     113         * Disambigued name not found.
     114         * Lets try our luck with possibly ambiguous "name" property.
     115         *
     116         * We need to do this because paths stored in "/aliases"
     117         * are not always fully-qualified.
     118         */
     119        for (cur = node->child; cur; cur = cur->peer) {
     120                if (strcmp(ofw_tree_node_name(cur), name) == 0)
     121                        return cur;
     122        }
     123               
    91124        return NULL;
    92125}
Note: See TracChangeset for help on using the changeset viewer.