fixed bug in pci_scan that prevented the handles array to be filled correctly
This commit is contained in:
5
Makefile
5
Makefile
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# can be either "Y" or "N" (without quotes). "Y" for using the m68k-elf-, "N" for using the m68k-atari-mint
|
# can be either "Y" or "N" (without quotes). "Y" for using the m68k-elf-, "N" for using the m68k-atari-mint
|
||||||
# toolchain
|
# toolchain
|
||||||
COMPILE_ELF=N
|
COMPILE_ELF=Y
|
||||||
|
|
||||||
ifeq (Y,$(COMPILE_ELF))
|
ifeq (Y,$(COMPILE_ELF))
|
||||||
TCPREFIX=m68k-elf-
|
TCPREFIX=m68k-elf-
|
||||||
@@ -118,6 +118,7 @@ lib: $(LIBS)
|
|||||||
do rm -f $$d/*.map $$d/*.s19 $$d/*.elf $$d/*.lk $$d/objs/* ;\
|
do rm -f $$d/*.map $$d/*.s19 $$d/*.elf $$d/*.lk $$d/objs/* ;\
|
||||||
done
|
done
|
||||||
rm -f depend
|
rm -f depend
|
||||||
|
rm -f tags
|
||||||
|
|
||||||
|
|
||||||
# flags for targets
|
# flags for targets
|
||||||
@@ -202,6 +203,8 @@ depend: $(ASRCS) $(CSRCS)
|
|||||||
do $(CC) $(CFLAGS) $(INCLUDE) -M $(ASRCS) $(CSRCS) | sed -e "s#^\(.*\).o:#$$d/objs/\1.o:#" >> depend; \
|
do $(CC) $(CFLAGS) $(INCLUDE) -M $(ASRCS) $(CSRCS) | sed -e "s#^\(.*\).o:#$$d/objs/\1.o:#" >> depend; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
tags: $(ASRCS) $(CSRCS) include/*
|
||||||
|
ctags -R sources include
|
||||||
|
|
||||||
ifneq (clean,$(MAKECMDGOALS))
|
ifneq (clean,$(MAKECMDGOALS))
|
||||||
-include depend
|
-include depend
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "bas_types.h"
|
#include "bas_types.h"
|
||||||
|
|
||||||
|
#if MACHINE_FIREBEE
|
||||||
|
#include "firebee.h"
|
||||||
|
#elif MACHINE_M5484LITE
|
||||||
|
#include "m5484l.h"
|
||||||
|
#endif /* MACHINE_FIREBEE */
|
||||||
|
|
||||||
#define AMD_FLASH_BUS_SHIFT 1
|
#define AMD_FLASH_BUS_SHIFT 1
|
||||||
#define AMD_FLASH_CELL volatile uint16_t
|
#define AMD_FLASH_CELL volatile uint16_t
|
||||||
#define AMD_FLASH_CELL_BYTES 2
|
#define AMD_FLASH_CELL_BYTES 2
|
||||||
@@ -175,7 +181,7 @@ static const struct romram flash_areas[] =
|
|||||||
};
|
};
|
||||||
static const int num_flash_areas = sizeof(flash_areas) / sizeof(struct romram);
|
static const int num_flash_areas = sizeof(flash_areas) / sizeof(struct romram);
|
||||||
|
|
||||||
#define FLASH_ADDRESS 0xe0000000
|
#define FLASH_ADDRESS BOOTFLASH_BASE_ADDRESS
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* erase a flash sector
|
* erase a flash sector
|
||||||
|
|||||||
@@ -32,6 +32,9 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "wait.h"
|
#include "wait.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PCI device class descriptions displayed during PCI bus scan
|
||||||
|
*/
|
||||||
static struct pci_class
|
static struct pci_class
|
||||||
{
|
{
|
||||||
int classcode;
|
int classcode;
|
||||||
@@ -58,18 +61,34 @@ static struct pci_class
|
|||||||
{ 0x11, "Data Acquisition and Signal Processing Controller" },
|
{ 0x11, "Data Acquisition and Signal Processing Controller" },
|
||||||
{ 0xff, "Device does not fit any defined class" },
|
{ 0xff, "Device does not fit any defined class" },
|
||||||
};
|
};
|
||||||
static int num_classes = sizeof(pci_classes) / sizeof(struct pci_class);
|
static int num_pci_classes = sizeof(pci_classes) / sizeof(struct pci_class);
|
||||||
|
|
||||||
#define NUM_CARDS 10
|
#define NUM_CARDS 10
|
||||||
#define NUM_RESOURCES 6
|
#define NUM_RESOURCES 6
|
||||||
uint16_t handles[NUM_CARDS]; /* holds the handle of a card at position = array index */
|
/* holds the handle of a card at position = array index */
|
||||||
static struct pci_rd resource_descriptors[NUM_CARDS][NUM_RESOURCES]; /* FIXME: fix number of cards */
|
static uint16_t handles[NUM_CARDS];
|
||||||
|
/* holds the card's resource descriptors; filled in pci_device_config() */
|
||||||
|
static struct pci_rd resource_descriptors[NUM_CARDS][NUM_RESOURCES];
|
||||||
|
|
||||||
|
static int16_t handle2index(int16_t handle)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_CARDS; i++)
|
||||||
|
{
|
||||||
|
if (handles[i] == handle)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static char *device_class(int classcode)
|
static char *device_class(int classcode)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_classes; i++)
|
for (i = 0; i < num_pci_classes; i++)
|
||||||
{
|
{
|
||||||
if (pci_classes[i].classcode == classcode)
|
if (pci_classes[i].classcode == classcode)
|
||||||
{
|
{
|
||||||
@@ -174,12 +193,9 @@ void pci_write_config_longword(uint16_t handle, uint16_t offset, uint32_t value)
|
|||||||
*/
|
*/
|
||||||
struct pci_rd *pci_get_resource(uint16_t handle)
|
struct pci_rd *pci_get_resource(uint16_t handle)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
for (i = 0; i < NUM_CARDS; i++)
|
index = handle2index(handle);
|
||||||
if (handles[i] == handle)
|
|
||||||
index = i;
|
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
return resource_descriptors[index];
|
return resource_descriptors[index];
|
||||||
@@ -263,7 +279,7 @@ static void pci_device_config(uint16_t bus, uint16_t slot, uint16_t function)
|
|||||||
{
|
{
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
uint16_t handle;
|
uint16_t handle;
|
||||||
uint16_t index = - 1;
|
int16_t index = - 1;
|
||||||
struct pci_rd *descriptors;
|
struct pci_rd *descriptors;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -271,14 +287,8 @@ static void pci_device_config(uint16_t bus, uint16_t slot, uint16_t function)
|
|||||||
handle = PCI_HANDLE(bus, slot, function);
|
handle = PCI_HANDLE(bus, slot, function);
|
||||||
|
|
||||||
/* find index into resource descriptor table for handle */
|
/* find index into resource descriptor table for handle */
|
||||||
for (i = 0; i < NUM_CARDS; i++)
|
index = handle2index(handle);
|
||||||
{
|
|
||||||
if (handles[i] == handle)
|
|
||||||
{
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
xprintf("cannot find index for handle %d\r\n", handle);
|
xprintf("cannot find index for handle %d\r\n", handle);
|
||||||
@@ -303,7 +313,9 @@ static void pci_device_config(uint16_t bus, uint16_t slot, uint16_t function)
|
|||||||
//(IS_PCI_MEM_BAR(value) ? PCI_MEMBAR_ADR(value) : PCI_IOBAR_ADR(value)),
|
//(IS_PCI_MEM_BAR(value) ? PCI_MEMBAR_ADR(value) : PCI_IOBAR_ADR(value)),
|
||||||
//(IS_PCI_MEM_BAR(value) ? ~(address & 0xfffffff0) + 1 : ~(address & 0xfffffffc) + 1));
|
//(IS_PCI_MEM_BAR(value) ? ~(address & 0xfffffff0) + 1 : ~(address & 0xfffffffc) + 1));
|
||||||
|
|
||||||
/* adjust base address to alignment requirements */
|
struct pci_rd *rd = &descriptors[barnum];
|
||||||
|
|
||||||
|
/* adjust base address to card's alignment requirements */
|
||||||
if (IS_PCI_MEM_BAR(value))
|
if (IS_PCI_MEM_BAR(value))
|
||||||
{
|
{
|
||||||
int size = ~(address & 0xfffffff0) + 1;
|
int size = ~(address & 0xfffffff0) + 1;
|
||||||
@@ -320,12 +332,12 @@ static void pci_device_config(uint16_t bus, uint16_t slot, uint16_t function)
|
|||||||
//xprintf("BAR[%d] configured to %08x, size %x\r\n", i, value, size);
|
//xprintf("BAR[%d] configured to %08x, size %x\r\n", i, value, size);
|
||||||
|
|
||||||
/* fill resource descriptor */
|
/* fill resource descriptor */
|
||||||
descriptors[barnum].next = sizeof(struct pci_rd);
|
rd->next = sizeof(struct pci_rd);
|
||||||
descriptors[barnum].flags = 0 | FLG_8BIT | FLG_16BIT | FLG_32BIT | 1;
|
rd->flags = 0 | FLG_8BIT | FLG_16BIT | FLG_32BIT | ORD_MOTOROLA;
|
||||||
descriptors[barnum].start = mem_address;
|
rd->start = mem_address;
|
||||||
descriptors[barnum].length = size;
|
rd->length = size;
|
||||||
descriptors[barnum].offset = 0;
|
rd->offset = 0;
|
||||||
descriptors[barnum].dmaoffset = 0;
|
rd->dmaoffset = 0;
|
||||||
|
|
||||||
/* adjust memory adress for next turn */
|
/* adjust memory adress for next turn */
|
||||||
mem_address += size;
|
mem_address += size;
|
||||||
@@ -349,12 +361,12 @@ static void pci_device_config(uint16_t bus, uint16_t slot, uint16_t function)
|
|||||||
//xprintf("BAR[%d] mapped to %08x, size %x\r\n", i, value, size);
|
//xprintf("BAR[%d] mapped to %08x, size %x\r\n", i, value, size);
|
||||||
|
|
||||||
/* fill resource descriptor */
|
/* fill resource descriptor */
|
||||||
descriptors[barnum].next = sizeof(struct pci_rd);
|
rd->next = sizeof(struct pci_rd);
|
||||||
descriptors[barnum].flags = FLG_IO | FLG_8BIT | FLG_16BIT | FLG_32BIT | 1;
|
rd->flags = FLG_IO | FLG_8BIT | FLG_16BIT | FLG_32BIT | 1;
|
||||||
descriptors[barnum].start = io_address;
|
rd->start = io_address;
|
||||||
descriptors[barnum].offset = PCI_MEMORY_OFFSET;
|
rd->offset = PCI_MEMORY_OFFSET;
|
||||||
descriptors[barnum].length = size;
|
rd->length = size;
|
||||||
descriptors[barnum].dmaoffset = PCI_MEMORY_OFFSET;
|
rd->dmaoffset = PCI_MEMORY_OFFSET;
|
||||||
|
|
||||||
/* adjust I/O adress for next turn */
|
/* adjust I/O adress for next turn */
|
||||||
io_address += size;
|
io_address += size;
|
||||||
@@ -374,7 +386,7 @@ void pci_scan(void)
|
|||||||
uint16_t bus;
|
uint16_t bus;
|
||||||
uint16_t slot;
|
uint16_t slot;
|
||||||
uint16_t function;
|
uint16_t function;
|
||||||
uint16_t index = 0;
|
int16_t index = 0;
|
||||||
|
|
||||||
xprintf("\r\nPCI bus scan...\r\n\r\n");
|
xprintf("\r\nPCI bus scan...\r\n\r\n");
|
||||||
xprintf(" Bus|Slot|Func|Vndr|Dev |\r\n");
|
xprintf(" Bus|Slot|Func|Vndr|Dev |\r\n");
|
||||||
@@ -399,7 +411,7 @@ void pci_scan(void)
|
|||||||
if (PCI_VENDOR_ID(value) != 0x1057 && PCI_DEVICE_ID(value) != 0x5806) /* do not configure bridge */
|
if (PCI_VENDOR_ID(value) != 0x1057 && PCI_DEVICE_ID(value) != 0x5806) /* do not configure bridge */
|
||||||
{
|
{
|
||||||
/* save handle to index value so that we later find our resources again */
|
/* save handle to index value so that we later find our resources again */
|
||||||
handles[index] = PCI_HANDLE(bus, slot, function);
|
handles[index++] = PCI_HANDLE(bus, slot, function);
|
||||||
|
|
||||||
/* configure memory and I/O for card */
|
/* configure memory and I/O for card */
|
||||||
pci_device_config(bus, slot, function);
|
pci_device_config(bus, slot, function);
|
||||||
|
|||||||
Reference in New Issue
Block a user