From a2b41c11d2313e5e12507ae5ca0a507c2d3d05de Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Tue, 9 Nov 2021 00:19:53 -0800 Subject: [PATCH] [dev][pci] move the pci console commands into the pci bus driver Remove app/pcitests since it was just the console commands. --- app/pcitests/rules.mk | 10 ---------- app/pcitests/pci_tests.c => dev/bus/pci/debug.c | 0 dev/bus/pci/pci.c | 14 ++++++++++++++ dev/bus/pci/rules.mk | 1 + platform/pc/rules.mk | 2 -- project/target/pc.mk | 1 - 6 files changed, 15 insertions(+), 13 deletions(-) delete mode 100644 app/pcitests/rules.mk rename app/pcitests/pci_tests.c => dev/bus/pci/debug.c (100%) diff --git a/app/pcitests/rules.mk b/app/pcitests/rules.mk deleted file mode 100644 index 35eececd..00000000 --- a/app/pcitests/rules.mk +++ /dev/null @@ -1,10 +0,0 @@ -LOCAL_DIR := $(GET_LOCAL_DIR) - -MODULE := $(LOCAL_DIR) - -MODULE_SRCS += \ - $(LOCAL_DIR)/pci_tests.c - -MODULE_DEPS += dev/bus/pci - -include make/module.mk diff --git a/app/pcitests/pci_tests.c b/dev/bus/pci/debug.c similarity index 100% rename from app/pcitests/pci_tests.c rename to dev/bus/pci/debug.c diff --git a/dev/bus/pci/pci.c b/dev/bus/pci/pci.c index 848f37ae..9eedc2b3 100644 --- a/dev/bus/pci/pci.c +++ b/dev/bus/pci/pci.c @@ -45,7 +45,10 @@ int (*g_pci_set_irq_hw_int)(const pci_location_t *state, uint8_t int_pin, uint8_ /* user facing routines */ int pci_find_pci_device(pci_location_t *state, uint16_t device_id, uint16_t vendor_id, uint16_t index) { + LTRACEF("device_id dev %#hx vendor %#hx index %#hx\n", device_id, vendor_id, index); + if (unlikely(!g_pci_find_pci_device)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } @@ -60,7 +63,10 @@ int pci_find_pci_device(pci_location_t *state, uint16_t device_id, uint16_t vend } int pci_find_pci_class_code(pci_location_t *state, uint32_t class_code, uint16_t index) { + LTRACEF("device_id class %#x index %#hx\n", class_code, index); + if (unlikely(!g_pci_find_pci_class_code)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } @@ -76,6 +82,7 @@ int pci_find_pci_class_code(pci_location_t *state, uint32_t class_code, uint16_t int pci_read_config_byte(const pci_location_t *state, uint32_t reg, uint8_t *value) { if (unlikely(!g_pci_read_config_byte)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } @@ -90,6 +97,7 @@ int pci_read_config_byte(const pci_location_t *state, uint32_t reg, uint8_t *val } int pci_read_config_half(const pci_location_t *state, uint32_t reg, uint16_t *value) { if (unlikely(!g_pci_read_config_half)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } @@ -105,6 +113,7 @@ int pci_read_config_half(const pci_location_t *state, uint32_t reg, uint16_t *va int pci_read_config_word(const pci_location_t *state, uint32_t reg, uint32_t *value) { if (unlikely(!g_pci_read_config_word)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } @@ -120,6 +129,7 @@ int pci_read_config_word(const pci_location_t *state, uint32_t reg, uint32_t *va int pci_write_config_byte(const pci_location_t *state, uint32_t reg, uint8_t value) { if (unlikely(!g_pci_write_config_byte)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } @@ -135,6 +145,7 @@ int pci_write_config_byte(const pci_location_t *state, uint32_t reg, uint8_t val int pci_write_config_half(const pci_location_t *state, uint32_t reg, uint16_t value) { if (unlikely(!g_pci_write_config_half)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } @@ -150,6 +161,7 @@ int pci_write_config_half(const pci_location_t *state, uint32_t reg, uint16_t va int pci_write_config_word(const pci_location_t *state, uint32_t reg, uint32_t value) { if (unlikely(!g_pci_write_config_word)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } @@ -166,6 +178,7 @@ int pci_write_config_word(const pci_location_t *state, uint32_t reg, uint32_t va int pci_get_irq_routing_options(irq_routing_entry *entries, uint16_t *count, uint16_t *pci_irqs) { if (unlikely(!g_pci_get_irq_routing_options)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } @@ -189,6 +202,7 @@ int pci_get_irq_routing_options(irq_routing_entry *entries, uint16_t *count, uin int pci_set_irq_hw_int(const pci_location_t *state, uint8_t int_pin, uint8_t irq) { if (unlikely(!g_pci_set_irq_hw_int)) { + LTRACEF("not configured\n"); return ERR_NOT_CONFIGURED; } diff --git a/dev/bus/pci/rules.mk b/dev/bus/pci/rules.mk index 5093a4a7..8333c04b 100644 --- a/dev/bus/pci/rules.mk +++ b/dev/bus/pci/rules.mk @@ -4,6 +4,7 @@ MODULE := $(LOCAL_DIR) MODULE_SRCS += \ $(LOCAL_DIR)/bios32.c \ + $(LOCAL_DIR)/debug.c \ $(LOCAL_DIR)/pci.c \ $(LOCAL_DIR)/type1.c \ diff --git a/platform/pc/rules.mk b/platform/pc/rules.mk index b19daddd..9a4fa76d 100644 --- a/platform/pc/rules.mk +++ b/platform/pc/rules.mk @@ -23,7 +23,5 @@ MODULE_SRCS += \ LK_HEAP_IMPLEMENTATION ?= dlmalloc -MODULE_DEPS += app/pcitests - include make/module.mk diff --git a/project/target/pc.mk b/project/target/pc.mk index 14907f61..3a469f17 100644 --- a/project/target/pc.mk +++ b/project/target/pc.mk @@ -5,4 +5,3 @@ SUBARCH ?= x86-32 TARGET := pc-x86 MODULES += \ app/shell \ - app/pcitests