Skip to content

Commit

Permalink
Add list of addresses to probe for FE board
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasekstrom committed Sep 10, 2023
1 parent cb98711 commit 6f4e7b8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Software/a314device/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct A314Device
UWORD is_a600;

ULONG fw_flags;
#elif defined(MODEL_FE)
ULONG a314_mem_address;
#endif

#if defined(MODEL_TD) || defined(MODEL_FE)
Expand Down
8 changes: 3 additions & 5 deletions Software/a314device/fix_mem_region.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ extern ULONG check_a314_mapping(__reg("a0") void *address);
#define ONE_MB (1024*1024)
#define TWO_MB (2*1024*1024)

#define FE_BANK_ADDRESS 0x40000

struct MemChunkList
{
struct MemChunk *first;
Expand Down Expand Up @@ -325,7 +323,7 @@ BOOL fix_memory(struct A314Device *dev)
BOOL fix_memory(struct A314Device *dev)
{
Forbid();
mark_region_a314(FE_BANK_ADDRESS, QUARTER_MB);
mark_region_a314(dev->a314_mem_address, QUARTER_MB);
Permit();
return TRUE;
}
Expand Down Expand Up @@ -354,7 +352,7 @@ static ULONG cpu_to_a314_address(__reg("a6") struct A314Device *dev, __reg("a0")
return HALF_MB + offset;
}
#elif defined(MODEL_FE)
ULONG offset = (ULONG)address - FE_BANK_ADDRESS;
ULONG offset = (ULONG)address - dev->a314_mem_address;
if (offset < QUARTER_MB)
return offset;
#endif
Expand All @@ -369,7 +367,7 @@ static void *a314_to_cpu_address(__reg("a6") struct A314Device *dev, __reg("d0")
ULONG offset = address & ((1 << 19) - 1);
return (void *)(dev->bank_address[bank] + offset);
#elif defined(MODEL_FE)
return (void *)(FE_BANK_ADDRESS + address);
return (void *)(dev->a314_mem_address + address);
#endif
}

Expand Down
28 changes: 23 additions & 5 deletions Software/a314device/pi_if_fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

#define SysBase (*(struct ExecBase **)4)

// TODO: Currently these values are hard coded.
// TODO: Currently the list of addresses to probe is hard coded.
// We may want to add more dynamic detection of where the
// shared memory ends up in the memory space.
#define FE_BANK_ADDRESS 0x40000
static ULONG probe_addresses[] = {0x040000, 0xC40000, INVALID_A314_ADDRESS};

#define QUARTER_MB (256*1024)

extern void IntServer();
Expand Down Expand Up @@ -81,14 +82,31 @@ static void set_com_area_base_address(struct A314Device *dev)
Enable();
}

int probe_pi_interface(struct A314Device *dev)
static int probe_board_address(struct A314Device *dev)
{
if (!check_overlap_region(FE_BANK_ADDRESS, FE_BANK_ADDRESS + QUARTER_MB))
if (!check_overlap_region(dev->a314_mem_address, dev->a314_mem_address + QUARTER_MB))
return FALSE;

if (!detect_board_present(FE_BANK_ADDRESS))
if (!detect_board_present(dev->a314_mem_address))
return FALSE;

return TRUE;
}

int probe_pi_interface(struct A314Device *dev)
{
for (int i = 0; ; i++)
{
ULONG address = probe_addresses[i];
if (address == INVALID_A314_ADDRESS)
return FALSE;

dev->a314_mem_address = address;

if (probe_board_address(dev))
break;
}

if (!fix_memory(dev))
return FALSE;

Expand Down

0 comments on commit 6f4e7b8

Please sign in to comment.