-
Notifications
You must be signed in to change notification settings - Fork 47
Update to RTEMS 6 with Libbsd and Legacy net support #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,8 +43,21 @@ | |
| * info of 100% free (but 100% of 0 is still 0). | ||
| * | ||
| */ | ||
| /* | ||
| * Updated to RTEMS 6 | ||
| * Contemporary Software | ||
| * Chris Johns <chris@contemporary.software> | ||
| */ | ||
| #include "epicsVersion.h" | ||
|
|
||
| #define RTEMS_VERSION_INT \ | ||
| VERSION_INT(__RTEMS_MAJOR__, __RTEMS_MINOR__, __RTEMS_REVISION__, 0) | ||
|
|
||
| #if RTEMS_VERSION_INT <= VERSION_INT(5, 0, 0, 0) | ||
| /* | ||
| * This define effects rtems.h includes on 4.10 and earlier | ||
| */ | ||
| #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ | ||
| #include <rtems.h> | ||
| #include <bsp.h> | ||
| #include <rtems/libcsupport.h> | ||
| #include <rtems/libio_.h> | ||
|
|
@@ -53,6 +66,9 @@ | |
| #include <sys/socket.h> | ||
| #include <net/if.h> | ||
| #include <net/if_var.h> | ||
| #endif /* RTEMS 5 and earlier */ | ||
|
|
||
| #include <rtems.h> | ||
|
|
||
| #undef malloc | ||
| #undef free | ||
|
|
@@ -67,17 +83,36 @@ | |
| #include <string.h> | ||
| #include <stdlib.h> | ||
|
|
||
| #include "epicsVersion.h" | ||
| #if RTEMS_VERSION_INT < VERSION_INT(6, 0, 0, 0) | ||
| #define rtems_bsd_reset() bsp_reset() | ||
| #else /* RTEMS_VERSION_INT < VERSION_INT(6, 0, 0, 0) */ | ||
| #define rtems_bsd_reset() bsp_reset() | ||
| #endif /* RTEMS_VERSION_INT < VERSION_INT(6, 0, 0, 0) */ | ||
|
|
||
| #define RTEMS_VERSION_INT \ | ||
| VERSION_INT(__RTEMS_MAJOR__, __RTEMS_MINOR__, __RTEMS_REVISION__, 0) | ||
| #if RTEMS_LEGACY_STACK | ||
|
|
||
| #include <rtems/rtems_bsdnet.h> | ||
|
|
||
| #define sysBootLine rtems_bsdnet_bootp_cmdline | ||
| #else | ||
| #define sysBootLine "BOOTP cmdline not supported" | ||
| #endif | ||
| /* Override default STARTUP environment variable to use INIT */ | ||
| #undef STARTUP | ||
| #define STARTUP "INIT" | ||
|
|
||
| #define CLUSTSIZES 2 /* only regular mbufs and clusters */ | ||
|
|
||
| #if RTEMS_VERSION_INT >= VERSION_INT(6, 0, 0, 0) | ||
|
|
||
| #define NO_OF_CPUS rtems_configuration_get_maximum_processors() | ||
|
|
||
| #include <bsp/bootcard.h> | ||
| static inline void reboot(int val) { | ||
| (void)val; | ||
| bsp_reset(RTEMS_FATAL_SOURCE_APPLICATION, 112233); | ||
| } | ||
|
Comment on lines
+111
to
+114
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this use the RTEMS higher-level APIs instead of the BSP one?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would If we set
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I see this setting as a per BSP or hardware specific settings combined with the system requirements. I am not comfortable having this setting be made a requirement for EPICS as it makes a fragile link between a BSP configuration, the BSP default and EPICS. And I doubt the calls are consistently implemented in all BSPs so both options work. The option lets a BSP return to the boot loader or a reset happen. Some BSPs do not have a means to return to a boot loader as the boot process is destructive and others it is easier as a boot loader can handle a reset, ie hardware security reasons. Should EPICS be consistent in how a device restarts? If yes then what role does a BSP reset have here in iocStats? As an example the MVME5500 or MVME2700 return the boot loader on |
||
| #else /* RTEMS 6 or later */ | ||
| #ifdef RTEMS_BSP_PGM_EXEC_AFTER /* only defined on uC5282 */ | ||
| #define reboot(x) bsp_reset(0) | ||
| #elif (defined(__PPC__) && RTEMS_VERSION_INT > VERSION_INT(4, 9, 0, 0)) | ||
|
|
@@ -91,3 +126,4 @@ | |
| #else | ||
| #define reboot(x) rtemsReboot() | ||
| #endif | ||
| #endif /* RTEMS 6 or later */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,38 @@ | |
|
|
||
| #include <devIocStats.h> | ||
|
|
||
| static double prev_total = 0; | ||
| static double prev_idle = 0; | ||
|
|
||
| #if __RTEMS_MAJOR__ >= 6 | ||
|
|
||
| #include <sys/resource.h> | ||
|
|
||
| static double oldActiveUsage; | ||
| static double oldIdleUsage; | ||
|
|
||
| /* | ||
| * See IEEE Std 1003.1-1988 (“POSIX.1”) for getrusage() | ||
| */ | ||
| static void cpu_ticks(double *total, double *idle) { | ||
| struct rusage stats; | ||
| double curActive; | ||
| double curIdle; | ||
| getrusage(RUSAGE_SELF, &stats); | ||
| curActive = (double)stats.ru_utime.tv_sec + stats.ru_utime.tv_usec / 1e6; | ||
| curIdle = (double)stats.ru_stime.tv_sec + stats.ru_stime.tv_usec / 1e6; | ||
| *idle = curIdle - oldIdleUsage; | ||
| *total = *idle + (curActive - oldActiveUsage); | ||
| oldActiveUsage = curActive; | ||
| oldIdleUsage = curIdle; | ||
|
Comment on lines
+68
to
+74
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vijay says there may be a proper RTEMS API coming for this, but only for RTEMS-7; if so that would be a good change to make use of for the supported RTEMS version(s).
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which API is this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was talking about I haven't looked at how well it fits in here, but looks like the rtems API can be used here instead of custom coding it again. This code might get stale again if RTEMS is updated, and it will likely be easier to use an rtems api instead of implementing it here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about using rtems_task_iterate() to loop over each task and sum the values of _Thread_Get_CPU_time_used(task)? Unfortunately, _Thread_Get_CPU_time_used() seems to be a score function, but if there's no alternative yet perhaps its the best option for now. I think its been around since RTEMS 5.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes this is at the core of the approach I used in getusage back in 2024.
In the early days of EPICS integration we were not strict as everyone worked to get something going. The downside of this is we are still paying the price today as we extract EPICS from deep inside RTEMS. A key part of this effort is epics-base/epics-base#905.
Ah OK, the GSoC project. That call fills the gap of
It is per thread and yes correct. I am little confused by this discussion as I thought I had done this and exported the result via the standards supported getrusage call back in July 2024? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| #else /* RTEMS 6 or later */ | ||
|
|
||
| /* | ||
| * Direct access to the Object information table | ||
| */ | ||
|
|
||
| #if (__RTEMS_MAJOR__ > 4) || (__RTEMS_MAJOR__ == 4 && __RTEMS_MINOR__ > 7) | ||
| typedef char objName[13]; | ||
| #define RTEMS_OBJ_GET_NAME(tc, name) \ | ||
|
|
@@ -79,9 +111,6 @@ typedef char *objName; | |
| * from the RTEMS source. | ||
| */ | ||
|
|
||
| static double prev_total = 0; | ||
| static double prev_idle = 0; | ||
|
|
||
| static void cpu_ticks(double *total, double *idle) { | ||
| Objects_Information *obj; | ||
| Thread_Control *tc; | ||
|
|
@@ -116,6 +145,8 @@ static void cpu_ticks(double *total, double *idle) { | |
| } | ||
| } | ||
|
|
||
| #endif /* RTEMS 6 or later */ | ||
|
|
||
| int devIocStatsInitCpuUsage(void) { | ||
| cpu_ticks(&prev_total, &prev_idle); | ||
| #ifdef SSRLAPPSMISCUTILS | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are both arms of this
if()statement identical?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question and it has been a while.
It looks like a why to separate the pre-6 functionality from the 6 and later function to call. It can be reverted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're probably not meant to be identical — looks like a leftover from splitting the
#if/#else.A few lines further down, the RTEMS 6
reboot()redefinition uses the two-argument RTEMS 6bsp_reset()signature:but the RTEMS-6 arm of
rtems_bsd_reset()right above it still calls the old zero-argument form. My guess is the#elsebranch was meant to be:to match
reboot(), and got missed when the conditional was split out. Worth double-checking against the actual RTEMS 6bsp_reset()prototype either way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the name be
rtems_bsp_reset()and notrtems_bsd_reset()?Yes I agree. Thanks for the analysis. I checked and RTEMS 5 and I guess earlier have:
and RTEMS 6 and later has: