GitLab has been upgraded to 13.11.3 If you encounter any issues mail code@riscosopen.org

Commit 68ccdad8 authored by Jeffrey Lee's avatar Jeffrey Lee Committed by ROOL
Browse files

Use OS_Memory 65

Instead of manually poking around in the page tables, use OS_Memory 65
for logical -> physical address translation of the controller address.

Version 0.06. Tagged as 'EtherCPSW-0_06'
parent 4a16579f
/* (0.05)
/* (0.06)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 0.05
#define Module_MajorVersion_CMHG 0.06
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 18 May 2020
#define Module_Date_CMHG 03 May 2021
#define Module_MajorVersion "0.05"
#define Module_Version 5
#define Module_MajorVersion "0.06"
#define Module_Version 6
#define Module_MinorVersion ""
#define Module_Date "18 May 2020"
#define Module_Date "03 May 2021"
#define Module_ApplicationDate "18-May-20"
#define Module_ApplicationDate "03-May-21"
#define Module_ComponentName "EtherCPSW"
#define Module_FullVersion "0.05"
#define Module_HelpVersion "0.05 (18 May 2020)"
#define Module_LibraryVersionInfo "0:5"
#define Module_FullVersion "0.06"
#define Module_HelpVersion "0.06 (03 May 2021)"
#define Module_LibraryVersionInfo "0:6"
......@@ -943,7 +943,11 @@ _kernel_oserror *ethercp_init(const char *cmd_tail, int podule_base, void *pw)
error = ethercp_error_lookup((ethercp_err_t)ENOMEM);
goto init_fail;
}
obio_attach_from_hal_device(&oaa, device);
error = obio_attach_from_hal_device(&oaa, device);
if (error != NULL)
{
goto init_fail;
}
cpsw_ca.ca_attach(NULL, (device_t)softc, &oaa);
/* Probe how many MACs there are.
......
......@@ -45,6 +45,8 @@
#include "Global/HALEntries.h"
#include "Global/OSRSI6.h"
#include "Global/OSMisc.h"
#include "Global/OSMem.h"
#include "Global/NewErrors.h"
#include "EtherCPSWHdr.h"
#include "filtering.h"
......@@ -286,20 +288,40 @@ int intr_handler(_kernel_swi_regs *r, void *pw)
return 1;
}
void obio_attach_from_hal_device(struct obio_attach_args *oaa, struct device *device)
_kernel_oserror *obio_attach_from_hal_device(struct obio_attach_args *oaa, struct device *device)
{
const uint32_t *table;
uintptr_t phys, log;
_kernel_oserror *err;
uint64_t phys;
uintptr_t log;
uint32_t physlo, physhi;
/* There surely must be a nicer API to get hold of the physical address
* of some IO, rather than assuming OS_Memory maps in IO in 1MB chunks,
* and grubbing round in the L1PT, but seems not.
*/
_swix(OS_ReadSysInfo, _INR(0,2) | _OUT(2), 6, 0, OSRSI6_L1PT, &table);
log = (uintptr_t)device->address;
phys = table[log >> 20];
oaa->obio_addr = (phys & ~0xFFFFF) + (log & 0xFFFFF);
log = (uintptr_t)device->address;
err = _swix(OS_Memory, _INR(0,1) | _OUTR(0,1), OSMemReason_LogToPhys, log, &physlo, &physhi);
if (err == NULL)
{
phys = physlo | (((uint64_t)physhi) << 32);
}
else
{
const uint32_t *table;
if (err->errnum == ErrorNumber_BadAddress)
{
return err;
}
/* Assume any other error indicates that this is an old OS
* version where the OS_Memory call is unsupported. Resort to
* grubbing around in the L1PT (yuck!)
*/
_swix(OS_ReadSysInfo, _INR(0,2) | _OUT(2), 6, 0, OSRSI6_L1PT, &table);
phys = table[log >> 20];
phys = (phys & ~0xFFFFF) + (log & 0xFFFFF);
}
oaa->obio_addr = phys;
oaa->obio_intrbase = device->devicenumber;
return NULL;
}
/*
......
......@@ -214,7 +214,7 @@ struct obio_attach_args
uintptr_t obio_iot; /* Unused by RISC OS */
void *obio_dmat; /* Unused by RISC OS */
};
void obio_attach_from_hal_device(struct obio_attach_args *, struct device *);
_kernel_oserror *obio_attach_from_hal_device(struct obio_attach_args *, struct device *);
void intr_disestablish(void *);
void *intr_establish(int, int, int, int (*)(void *), void *);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment