Skip to content

Commit

Permalink
14450 Want PCI platform resource discovery module
Browse files Browse the repository at this point in the history
Reviewed by: Rich Lowe <richlowe@richlowe.net>
Reviewed by: Patrick Mooney <pmooney@pfmooney.com>
Reviewed by: Andy Fiddaman <andy@omnios.org>
Approved by: Dan McDonald <danmcd@joyent.com>
  • Loading branch information
rmustacc committed Feb 17, 2022
1 parent 55855f5 commit cd0d4b4
Show file tree
Hide file tree
Showing 16 changed files with 647 additions and 481 deletions.
2 changes: 2 additions & 0 deletions usr/src/pkg/manifests/system-kernel-platform.p5m
Expand Up @@ -559,6 +559,8 @@ $(i386_ONLY)file path=platform/i86pc/kernel/misc/$(ARCH64)/acpidev group=sys \
mode=0755
$(i386_ONLY)file path=platform/i86pc/kernel/misc/$(ARCH64)/gfx_private \
group=sys mode=0755
$(i386_ONLY)file path=platform/i86pc/kernel/misc/$(ARCH64)/pci_prd group=sys \
mode=0755
$(i386_ONLY)dir path=platform/i86pc/ucode group=sys
$(i386_ONLY)dir path=platform/i86xpv group=sys
$(i386_ONLY)dir path=platform/i86xpv/kernel group=sys
Expand Down
8 changes: 7 additions & 1 deletion usr/src/uts/common/sys/Makefile
Expand Up @@ -1125,6 +1125,9 @@ NXGEHDRS= \
nxge_virtual.h \
nxge_espc.h

PLATHDRS= \
pci_prd.h

include Makefile.syshdrs

dcam/%.check: dcam/%.h
Expand Down Expand Up @@ -1192,7 +1195,8 @@ CHECKHDRS= \
$(I1394HDRS:%.h=1394/%.check) \
$(RSMHDRS:%.h=rsm/%.check) \
$(TSOLHDRS:%.h=tsol/%.check) \
$(NXGEHDRS:%.h=nxge/%.check)
$(NXGEHDRS:%.h=nxge/%.check) \
$(PLATHDRS:%.h=plat/%.check)


.KEEP_STATE:
Expand Down Expand Up @@ -1232,6 +1236,7 @@ CHECKHDRS= \
$(ROOTTAVORHDRS) \
$(ROOTHERMONHDRS) \
$(ROOTMLNXHDRS) \
$(ROOTPLATHDRS) \
$(ROOTSCSIHDRS) \
$(ROOTSCSIADHDRS) \
$(ROOTSCSICONFHDRS) \
Expand Down Expand Up @@ -1300,6 +1305,7 @@ install_h: \
$(ROOTTAVORHDRS) \
$(ROOTHERMONHDRS) \
$(ROOTMLNXHDRS) \
$(ROOTPLATHDRS) \
$(ROOTSCSIHDRS) \
$(ROOTSCSIADHDRS) \
$(ROOTSCSIISCSIHDRS) \
Expand Down
130 changes: 130 additions & 0 deletions usr/src/uts/common/sys/plat/pci_prd.h
@@ -0,0 +1,130 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/

/*
* Copyright 2022 Oxide Computer Company
*/

#ifndef _SYS_PLAT_PCI_PRD_H
#define _SYS_PLAT_PCI_PRD_H

/*
* PCI Platform Resource Discovery (PRD)
*
* This file forms the platform-specific interfaces that a given platform must
* implement to support the discovery of PCI resources. In particular:
*
* o Any root complexes that do not show up through the use of normal scanning
* o Available resources per root-port including:
* + I/O ports
* + Prefetchable Memory
* + Normal Memory
* + PCI buses
* o The naming of slots (the platform uses the PCIe default)
*
* These interfaces are all expected to be implemented by a platform's 'pci_prd'
* module. This is left as a module and not a part of say, unix, so that it can
* in turn depend on other modules that a platform might require, such as ACPI.
*
* In general, unless otherwise indicated, these interfaces will always be
* called from kernel context, typically during boot. The interfaces will only
* be called from a single thread at this time and any locking is managed at a
* layer outside of the pci_prd interfaces. If the subsystem is using some other
* interfaces that may be used by multiple consumers and needs locking (e.g.
* ACPI), then that still must be considered in the design and implementation.
*/

#include <sys/types.h>
#include <sys/memlist.h>
#include <sys/sunddi.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
* Resource types that can be asked after.
*/
typedef enum pci_prd_rsrc {
PCI_PRD_R_IO,
PCI_PRD_R_MMIO,
PCI_PRD_R_PREFETCH,
PCI_PRD_R_BUS
} pci_prd_rsrc_t;

typedef struct pci_prd_upcalls {
/*
* Return a dev_info_t, if one exists, for this PCI bus.
*/
dev_info_t *(*pru_bus2dip_f)(uint32_t);
} pci_prd_upcalls_t;

/*
* Initialization and teardown functions that will be used by the PCI
* enumeration code when it attaches and detaches. If all work is done before
* these come up, there is nothing to do; however, after a call to the _init()
* function, it is expected that the platform module will be ready to respond to
* all function calls.
*
* Note that the _fini function may never be called as on a typical system, as
* any PCI(e) devices with attached drivers will result in the PRD consumer
* remaining loaded.
*/
extern int pci_prd_init(pci_prd_upcalls_t *);
extern void pci_prd_fini(void);

/*
* Return the maximum PCI bus on this platform that should be searched. This
* number is the last bus number that should be scanned. e.g. a value of 0x10
* indicates that we will search buses [0, 0x10]. In general, it is expected
* that platforms will just return 0xff (PCI_MAX_BUS_NUM - 1) unless for some
* reason it has other knowledge here.
*/
extern uint32_t pci_prd_max_bus(void);

/*
* Look up a set of resources that should be assigned to the PCI bus. In
* general, it is expected that these are only the buses that are assigned to
* root complexes.
*/
extern struct memlist *pci_prd_find_resource(uint32_t, pci_prd_rsrc_t);

/*
* Originally when only using BIOS-derived (pre-ACPI) sources on i86pc, the
* ability to utilize data about multiple buses was considered suspect. As such,
* this exists as a way to indicate that resources on each root complex are
* actually valid.
*/
extern boolean_t pci_prd_multi_root_ok(void);

/*
* This is used to allow the PCI enumeration code to ask the platform about any
* PCI root complexes that it might know about which might not be discovered
* through the normal scanning process. One callback will be emitted for each
* PCI bus via a call to the callback function. The return value of the callback
* function determines whether we should continue iterating (B_TRUE) or
* terminate (B_FALSE).
*/
typedef boolean_t (*pci_prd_root_complex_f)(uint32_t, void *);
extern void pci_prd_root_complex_iter(pci_prd_root_complex_f, void *);

/*
* Give the chance for a platform file to go through and use knowledge that it
* has (such as the traditional BIOS PCI IRQ routing table) to name the PCI(e)
* slot.
*/
extern void pci_prd_slot_name(uint32_t, dev_info_t *);

#ifdef __cplusplus
}
#endif

#endif /* _SYS_PLAT_PCI_PRD_H */
4 changes: 3 additions & 1 deletion usr/src/uts/i86pc/Makefile.files
Expand Up @@ -25,7 +25,7 @@
# Copyright (c) 2010, Intel Corporation.
# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
# Copyright 2020 Joyent, Inc.
# Copyright 2021 Oxide Computer Company
# Copyright 2022 Oxide Computer Company
# Copyright 2021 Jason King
#
# This Makefile defines file modules in the directory uts/i86pc
Expand Down Expand Up @@ -287,6 +287,8 @@ VIONA_OBJS += viona_main.o \

PPT_OBJS += ppt.o

PCI_PRD_OBJS += pci_prd_i86pc.o pci_memlist.o

#
# Build up defines and paths.
#
Expand Down
2 changes: 1 addition & 1 deletion usr/src/uts/i86pc/Makefile.i86pc
Expand Up @@ -293,7 +293,7 @@ SYS_KMODS +=
#
# 'Misc' Modules (/kernel/misc):
#
MISC_KMODS += gfx_private pcie
MISC_KMODS += gfx_private pcie pci_prd
MISC_KMODS += acpidev
MISC_KMODS += drmach_acpi

Expand Down
Expand Up @@ -29,8 +29,6 @@
#ifndef _MPS_TABLE_H
#define _MPS_TABLE_H

#pragma ident "%Z%%M% %I% %E% SMI"

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -42,7 +40,7 @@ struct mps_fps_hdr { /* MP Floating Pointer Structure */
uchar_t fps_len; /* in paragraph (16-bytes units) */
uchar_t fps_spec_rev; /* MP Spec. version no. */
uchar_t fps_cksum; /* checksum of complete structure */
uchar_t fps_featinfo1; /* mp feature info byte 1 */
uchar_t fps_featinfo1; /* mp feature info byte 1 */
uchar_t fps_featinfo2; /* mp feature info byte 2 */
uchar_t fps_featinfo3; /* mp feature info byte 3 */
uchar_t fps_featinfo4; /* mp feature info byte 4 */
Expand All @@ -51,7 +49,7 @@ struct mps_fps_hdr { /* MP Floating Pointer Structure */

struct mps_ct_hdr { /* MP Configuration Table Header */
uint32_t ct_sig; /* "PCMP" */
uint16_t ct_len; /* base configuration in bytes */
uint16_t ct_len; /* base configuration in bytes */
uchar_t ct_spec_rev; /* MP Spec. version no. */
uchar_t ct_cksum; /* base configuration table checksum */
char ct_oem_id[8]; /* string identifies the manufacturer */
Expand All @@ -60,7 +58,7 @@ struct mps_ct_hdr { /* MP Configuration Table Header */
uint16_t ct_oem_tbl_len; /* size of base OEM table in bytes */
uint16_t ct_entry_cnt; /* no. of entries in the base table */
uint32_t ct_local_apic; /* paddr of local APIC */
uint16_t ct_ext_tbl_len; /* extended table in bytes */
uint16_t ct_ext_tbl_len; /* extended table in bytes */
uchar_t ct_ext_cksum; /* checksum for the extended table */
};

Expand Down

0 comments on commit cd0d4b4

Please sign in to comment.