Changeset 4a7c273 in mainline
- Timestamp:
- 2006-05-08T18:24:04Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 20a9b85
- Parents:
- fca4207
- Files:
-
- 12 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/include/stdio.h
rfca4207 r4a7c273 36 36 37 37 extern int puts(const char * str); 38 extern int putchar(int c); 38 39 39 40 extern int printf(const char *fmt, ...); -
libc/include/stdlib.h
rfca4207 r4a7c273 34 34 35 35 #define abort() _exit(1) 36 #define exit(status) _exit((status)) 36 37 37 38 #endif -
libc/include/string.h
rfca4207 r4a7c273 33 33 #include <types.h> 34 34 35 #define bzero(ptr, len) memset((ptr), 0, (len)) 36 35 37 void * memset(void *s, int c, size_t n); 36 38 void * memcpy(void *dest, void *src, size_t n); 37 39 38 40 size_t strlen(const char *str); 41 int strcmp(const char *str1, const char *str2); 42 char *strchr(const char *str, int c); 43 char *strrchr(const char *str, int c); 44 unsigned long strtol(const char *nptr, char **endptr, int base); 39 45 40 46 #endif -
pci/Makefile
rfca4207 r4a7c273 37 37 CFLAGS += -I../libipc/include 38 38 39 LIBS = $(LIBIPC_PREFIX)/libipc.a $(LIBC_PREFIX)/libc.a39 LIBS = libpci/libpci.a $(LIBC_PREFIX)/libc.a 40 40 41 41 ## Sources … … 56 56 clean: 57 57 -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend 58 $(MAKE) -C libpci clean 58 59 59 60 depend: … … 61 62 62 63 $(OUTPUT): $(OBJECTS) $(LIBS) 64 $(MAKE) -C libpci 63 65 $(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map 64 66 … … 74 76 %.o: %.c 75 77 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 78 79 libpci/libpci.a: 80 $(MAKE) -C libpci -
pci/pci.c
rfca4207 r4a7c273 1 1 /* 2 * HelenOS PCI driver. 3 * 4 * Copyright (C) 1997-2003 Martin Mares 2 5 * Copyright (C) 2006 Jakub Jermar 3 * All rights reserved.4 6 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 7 * (Based on libpci example.c written by Martin Mares.) 8 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 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 15 * derived from this software without specific prior written permission. 16 * 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 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 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 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 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 9 * Can be freely distributed and used under the terms of the GNU GPL. 27 10 */ 28 11 29 #include <ipc.h>30 12 #include <stdio.h> 31 13 #include <ddi.h> … … 33 15 #include <stdlib.h> 34 16 17 #include "libpci/pci.h" 18 19 #define PCI_CONF1 0xcf8 20 #define PCI_CONF1_SIZE 8 21 35 22 int main(int argc, char *argv[]) 36 23 { 24 struct pci_access *pacc; 25 struct pci_dev *dev; 26 unsigned int c; 27 char buf[80]; 28 37 29 printf("HelenOS PCI driver\n"); 30 31 /* 32 * Gain control over PCI configuration ports. 33 */ 34 iospace_enable(task_get_id(), (void *) PCI_CONF1, PCI_CONF1_SIZE); 35 36 pacc = pci_alloc(); /* Get the pci_access structure */ 37 pci_init(pacc); /* Initialize the PCI library */ 38 pci_scan_bus(pacc); /* We want to get the list of devices */ 39 for(dev=pacc->devices; dev; dev=dev->next) { /* Iterate over all devices */ 40 pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES); /* Fill in header info we need */ 41 c = pci_read_word(dev, PCI_CLASS_DEVICE); /* Read config register directly */ 42 printf("%02x:%02x.%d vendor=%04x device=%04x class=%04x irq=%d base0=%lx\n", 43 dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id, 44 c, dev->irq, dev->base_addr[0]); 45 printf("\t%s\n", pci_lookup_name(pacc, buf, sizeof(buf), PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE, 46 dev->vendor_id, dev->device_id)); 47 } 48 pci_cleanup(pacc); /* Close everything */ 49 38 50 return 0; 39 51 }
Note:
See TracChangeset
for help on using the changeset viewer.