Annotation of qemu/roms/SLOF/clients/net-snk/oflib/pci.c, revision 1.1.1.1

1.1       root        1: /******************************************************************************
                      2:  * Copyright (c) 2004, 2008 IBM Corporation
                      3:  * All rights reserved.
                      4:  * This program and the accompanying materials
                      5:  * are made available under the terms of the BSD License
                      6:  * which accompanies this distribution, and is available at
                      7:  * http://www.opensource.org/licenses/bsd-license.php
                      8:  *
                      9:  * Contributors:
                     10:  *     IBM Corporation - initial implementation
                     11:  *****************************************************************************/
                     12: 
                     13: #include <rtas.h>
                     14: #include <of.h>
                     15: #include <pci.h>
                     16: #include <string.h>
                     17: #include <kernel.h>
                     18: #include <cpu.h>
                     19: #include <cache.h>
                     20: 
                     21: int
                     22: pci_calc_bar_size(long long puid, int bus, int devfn, int bar)
                     23: {
                     24:        int size;
                     25:        int old;
                     26:        bar = bar * 4 + 0x10;
                     27:        old = rtas_pci_config_read(puid, 4, bus, devfn, bar);
                     28:        rtas_pci_config_write(puid, 4, bus, devfn, bar, 0xffffffff);
                     29:        size = (rtas_pci_config_read(puid, 4, bus, devfn, bar) & (-4)) * -1;
                     30:        rtas_pci_config_write(puid, 4, bus, devfn, bar, old);
                     31:        return size;
                     32: }
                     33: 
                     34: int
                     35: pci_get_bar_start(long long puid, int bus, int devfn, int bar)
                     36: {
                     37:        return rtas_pci_config_read(puid, 4, bus, devfn, bar * 4 + 0x10);
                     38: }
                     39: 
                     40: void
                     41: pci_set_bar_start(long long puid, int bus, int devfn, int bar, int value)
                     42: {
                     43:        rtas_pci_config_write(puid, 4, bus, devfn, bar * 4 + 0x10, value);
                     44: }
                     45: 
                     46: unsigned int
                     47: read_io(void *addr, size_t sz)
                     48: {
                     49:        unsigned int ret;
                     50: 
                     51:        switch (sz) {
                     52:        case 1:
                     53:                ret = ci_read_8(addr);
                     54:                break;
                     55:        case 2:
                     56:                ret = ci_read_16(addr);
                     57:                break;
                     58:        case 4:
                     59:                ret = ci_read_32(addr);
                     60:                break;
                     61:        default:
                     62:                ret = 0;
                     63:        }
                     64: 
                     65:        return ret;
                     66: }
                     67: 
                     68: int
                     69: write_io(void *addr, unsigned int value, size_t sz)
                     70: {
                     71:        switch (sz) {
                     72:        case 1:
                     73:                ci_write_8(addr, value);
                     74:                break;
                     75:        case 2:
                     76:                ci_write_16(addr, value);
                     77:                break;
                     78:        case 4:
                     79:                ci_write_32(addr, value);
                     80:                break;
                     81:        default:
                     82:                return -1;
                     83:        }
                     84: 
                     85:        return 0;
                     86: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.