samples: Add an application to print out PCI enumeration
This application can be used to list the PCI devices through the console. Change-Id: I3409ab9025b1f18a42b4cdd594fb095ebeac96f3 Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
a15c4a6be0
commit
c55e8861ab
9 changed files with 130 additions and 0 deletions
6
samples/microkernel/apps/pci_enum/Makefile
Normal file
6
samples/microkernel/apps/pci_enum/Makefile
Normal file
|
@ -0,0 +1,6 @@
|
|||
PLATFORM_CONFIG ?= galileo
|
||||
KERNEL_TYPE = micro
|
||||
MDEF_FILE = prj.mdef
|
||||
CONF_FILE = prj_$(ARCH).conf
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
5
samples/microkernel/apps/pci_enum/prj.mdef
Normal file
5
samples/microkernel/apps/pci_enum/prj.mdef
Normal file
|
@ -0,0 +1,5 @@
|
|||
% Application : PCI enumeration application
|
||||
|
||||
% TASK NAME PRIO ENTRY STACK GROUPS
|
||||
% ===========================================
|
||||
TASK TASKA 7 task_enum_pci 1024 [EXE]
|
3
samples/microkernel/apps/pci_enum/prj_x86.conf
Normal file
3
samples/microkernel/apps/pci_enum/prj_x86.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
CONFIG_STDOUT_CONSOLE=y
|
||||
CONFIG_PCI_ENUMERATION=y
|
||||
CONFIG_PCI_DEBUG=y
|
3
samples/microkernel/apps/pci_enum/src/Makefile
Normal file
3
samples/microkernel/apps/pci_enum/src/Makefile
Normal file
|
@ -0,0 +1,3 @@
|
|||
ccflags-y += ${PROJECTINCLUDE} -I${ZEPHYR_BASE}/include/drivers
|
||||
|
||||
obj-y = pci_enum.o
|
90
samples/microkernel/apps/pci_enum/src/pci_enum.c
Normal file
90
samples/microkernel/apps/pci_enum/src/pci_enum.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
/* pci_enum.c - PCI Enumeration print-out application */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1) Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3) Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <pci/pci.h>
|
||||
|
||||
#if defined(CONFIG_STDOUT_CONSOLE)
|
||||
#include <stdio.h>
|
||||
#define PRINT printf
|
||||
#else
|
||||
#include <misc/printk.h>
|
||||
#define PRINT printk
|
||||
#endif
|
||||
|
||||
void pci_enumerate(void)
|
||||
{
|
||||
struct pci_dev_info info = {
|
||||
.function = PCI_FUNCTION_ANY,
|
||||
.bar = PCI_BAR_ANY,
|
||||
};
|
||||
|
||||
pci_bus_scan_init();
|
||||
|
||||
while (pci_bus_scan(&info)) {
|
||||
pci_show(&info);
|
||||
info.class = 0;
|
||||
info.vendor_id = 0;
|
||||
info.device_id = 0;
|
||||
info.function = PCI_FUNCTION_ANY;
|
||||
info.bar = PCI_BAR_ANY;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MICROKERNEL
|
||||
|
||||
#include <zephyr.h>
|
||||
|
||||
static int done = 0;
|
||||
|
||||
void task_enum_pci(void)
|
||||
{
|
||||
if (done) {
|
||||
task_yield();
|
||||
}
|
||||
|
||||
pci_enumerate();
|
||||
|
||||
done = 1;
|
||||
}
|
||||
|
||||
#else /* CONFIG_NANOKERNEL */
|
||||
|
||||
#include <nanokernel.h>
|
||||
#include <arch/cpu.h>
|
||||
|
||||
void main(void)
|
||||
{
|
||||
pci_enumerate();
|
||||
}
|
||||
|
||||
#endif /* CONFIG_MICROKERNEL */
|
6
samples/microkernel/apps/pci_enum/testcase.ini
Normal file
6
samples/microkernel/apps/pci_enum/testcase.ini
Normal file
|
@ -0,0 +1,6 @@
|
|||
[test]
|
||||
build_only = true
|
||||
tags = apps
|
||||
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = galileo basic_minuteia
|
6
samples/nanokernel/apps/pci_enum/Makefile
Normal file
6
samples/nanokernel/apps/pci_enum/Makefile
Normal file
|
@ -0,0 +1,6 @@
|
|||
PLATFORM_CONFIG ?= galileo
|
||||
KERNEL_TYPE = nano
|
||||
CONF_FILE = prj_$(ARCH).conf
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/microkernel/apps/pci_enum/src/
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
5
samples/nanokernel/apps/pci_enum/prj_x86.conf
Normal file
5
samples/nanokernel/apps/pci_enum/prj_x86.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
CONFIG_STDOUT_CONSOLE=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_EARLY_CONSOLE=y
|
||||
CONFIG_PCI_ENUMERATION=y
|
||||
CONFIG_PCI_DEBUG=y
|
6
samples/nanokernel/apps/pci_enum/testcase.ini
Normal file
6
samples/nanokernel/apps/pci_enum/testcase.ini
Normal file
|
@ -0,0 +1,6 @@
|
|||
[test]
|
||||
build_only = true
|
||||
tags = apps
|
||||
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = galileo basic_minuteia
|
Loading…
Add table
Add a link
Reference in a new issue