[BACK]Return to obio.c CVS log [TXT][DIR] Up to [local] / funnyos / arch / testarm / dev

Annotation of funnyos/arch/testarm/dev/obio.c, Revision 1.1

1.1     ! init        1: /*
        !             2:  * $Id: obio.c,v 1.2 2007/10/12 08:54:20 init Exp $
        !             3:  */
        !             4: #include <sys/types.h>
        !             5: #include <sys/device.h>
        !             6: #include <sys/mem.h>
        !             7: #include <sys/bus.h>
        !             8: #include <libkern/printf.h>
        !             9:
        !            10: /*
        !            11:  * testarm obio (on-board i/o) support.
        !            12:  * This is a simple memory read/writes.
        !            13:  */
        !            14: uint8_t        obio_read_1(struct device *, uint32_t);
        !            15: uint16_t       obio_read_2(struct device *, uint32_t);
        !            16: uint32_t       obio_read_4(struct device *, uint32_t);
        !            17: int            obio_write_1(struct device *, uint32_t, uint8_t);
        !            18: int            obio_write_2(struct device *, uint32_t, uint16_t);
        !            19: int            obio_write_4(struct device *, uint32_t, uint32_t);
        !            20:
        !            21:
        !            22: int
        !            23: obio_attach(struct device *self)
        !            24: {
        !            25:        struct busops *aux = self->dv_aux;
        !            26:        aux = (struct busops *)kmalloc(sizeof(struct busops));
        !            27:        /*
        !            28:         * Link bus ops.
        !            29:         */
        !            30:        aux->bus_read_1 = obio_read_1;
        !            31:        aux->bus_read_2 = obio_read_2;
        !            32:        aux->bus_read_4 = obio_read_4;
        !            33:        aux->bus_write_1 = obio_write_1;
        !            34:        aux->bus_write_2 = obio_write_2;
        !            35:        aux->bus_write_4 = obio_write_4;
        !            36:
        !            37:        printf("memory-mapped i/o\n");
        !            38:
        !            39:        return(0);
        !            40: }
        !            41:
        !            42:
        !            43: uint8_t
        !            44: obio_read_1(struct device *devp, uint32_t addr)
        !            45: {
        !            46:        /*
        !            47:         * struct device is not used in obio.
        !            48:         * There is only one on-board i/o bus in testarm.
        !            49:         */
        !            50:        return( (*(uint8_t *)addr) );
        !            51: }
        !            52:
        !            53:
        !            54: uint16_t
        !            55: obio_read_2(struct device *devp, uint32_t addr)
        !            56: {
        !            57:        return( (*(uint16_t *)addr) );
        !            58: }
        !            59:
        !            60:
        !            61: uint32_t
        !            62: obio_read_4(struct device *devp, uint32_t addr)
        !            63: {
        !            64:        return( (*(uint32_t *)addr) );
        !            65: }
        !            66:
        !            67:
        !            68: int
        !            69: obio_write_1(struct device *devp, uint32_t addr, uint8_t data)
        !            70: {
        !            71:        *((uint8_t *)addr) = data;
        !            72:
        !            73:        /* XXX what about write errors? */
        !            74:        return(0);
        !            75: }
        !            76:
        !            77:
        !            78: int
        !            79: obio_write_2(struct device *devp, uint32_t addr, uint16_t data)
        !            80: {
        !            81:        *((uint16_t *)addr) = data;
        !            82:
        !            83:        return(0);
        !            84: }
        !            85:
        !            86:
        !            87: int
        !            88: obio_write_4(struct device *devp, uint32_t addr, uint32_t data)
        !            89: {
        !            90:        *((uint32_t *)addr) = data;
        !            91:
        !            92:        return(0);
        !            93: }
        !            94:

CVSweb