1 //=============================================================================
5 //=============================================================================
6 //####ECOSGPLCOPYRIGHTBEGIN####
7 // -------------------------------------------
8 // This file is part of eCos, the Embedded Configurable Operating System.
9 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
11 // eCos is free software; you can redistribute it and/or modify it under
12 // the terms of the GNU General Public License as published by the Free
13 // Software Foundation; either version 2 or (at your option) any later version.
15 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
16 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 // You should have received a copy of the GNU General Public License along
21 // with eCos; if not, write to the Free Software Foundation, Inc.,
22 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 // As a special exception, if other files instantiate templates or use macros
25 // or inline functions from this file, or you compile this file and link it
26 // with other works to produce a work based on this file, this file does not
27 // by itself cause the resulting work to be covered by the GNU General Public
28 // License. However the source code for this file must still be made available
29 // in accordance with section (3) of the GNU General Public License.
31 // This exception does not invalidate any other reasons why a work based on
32 // this file might be covered by the GNU General Public License.
34 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
35 // at http://sources.redhat.com/ecos/ecos-license/
36 // -------------------------------------------
37 //####ECOSGPLCOPYRIGHTEND####
38 //=============================================================================
39 //#####DESCRIPTIONBEGIN####
41 // Author(s): Scott Coulter, Jeff Frazier, Eric Breeden
42 // Contributors: Mark Salter
47 //####DESCRIPTIONEND####
49 //===========================================================================*/
52 #include <cyg/io/pci.h>
53 #include "test_menu.h"
55 extern int memTest (CYG_ADDRWORD startAddr, CYG_ADDRWORD endAddr);
60 // This test assumes that an IQ80310 eval board
61 // is installed in the secondary PCI slot. This
62 // second board must be configured with 32 Meg
67 pci_test (MENU_ARG arg)
69 cyg_pci_device dev_info;
70 cyg_pci_device_id devid;
73 cyg_uint32 *start, *end;
76 // First, look for iq80310 at private and public addresses
78 bus = (*ATU_PCIXSR >> 8) & 0xff;
82 devid = CYG_PCI_DEV_MAKE_ID(bus, CYG_PCI_DEV_MAKE_DEVFN(__SLOT_PUB, 1));
83 cyg_pci_get_device_info(devid, &dev_info);
85 if (dev_info.vendor != 0x8086 || dev_info.device != 0x530d) {
86 devid = CYG_PCI_DEV_MAKE_ID(bus, CYG_PCI_DEV_MAKE_DEVFN(__SLOT_PRIV, 1));
87 cyg_pci_get_device_info(devid, &dev_info);
89 if (dev_info.vendor != 0x8086 || dev_info.device != 0x530d) {
90 diag_printf("No iq80310 in PCI slot.\n");
95 cyg_pci_set_memory_base(HAL_PCI_ALLOC_BASE_MEMORY + 0x2000000);
96 cyg_pci_set_io_base(HAL_PCI_ALLOC_BASE_IO);
98 cyg_pci_configure_device(&dev_info);
100 diag_printf ("iq80310 DRAM starts at PCI address %p, CPU address %p\n",
101 dev_info.base_address[0] & CYG_PRI_CFG_BAR_MEM_MASK,
102 dev_info.base_map[0]);
104 // enable memory space and bus master
105 cyg_pci_read_config_uint16(dev_info.devid, CYG_PCI_CFG_COMMAND, &cmd);
106 cmd |= (CYG_PCI_CFG_COMMAND_MEMORY | CYG_PCI_CFG_COMMAND_MASTER);
107 cyg_pci_write_config_uint16(dev_info.devid, CYG_PCI_CFG_COMMAND, cmd);
109 start = (cyg_uint32 *)dev_info.base_map[0];
110 // skip over 1st Mbyte of target DRAM
111 start += 0x100000/sizeof(*start);
113 mem_size = 0x2000000 - 0x100000;
114 end = start + mem_size/sizeof(*start) - 1;
116 diag_printf("Testing memory from %p to %p.\n", start, end);
118 memTest((CYG_ADDRWORD)start, (CYG_ADDRWORD)end);
120 diag_printf ("Memory test done.\n");