chiark / gitweb /
hostside: more length for bavarian
[trains.git] / hostside / realtime.h
index 05e1c7561200c9adc972962f8356941a6358b5bd..d644ca21de773bdee6b1dc719fdb6551227b35e9 100644 (file)
 
 #include <fcntl.h>
 #include <dirent.h>
+#include <inttypes.h>
 
 #include <sys/types.h>
 #include <sys/time.h>
 
+#include "../.git-revid-autoversion.h"
 #include "../layout/layout-data.h"
 #include "realtime+dflags.h"
 
-typedef struct Segment Segment;
-typedef struct Train Train;
+typedef struct Segment Segment; /* from safety.h */
+typedef struct Train Train; /* from safety.h */
 typedef struct TimeoutEvent TimeoutEvent;
 
 /*---------- from retransmit.c ----------*/
@@ -36,7 +38,8 @@ typedef unsigned Retransmit__Time;
    * retransmit.c only; as a special exception, caller may edit pi
    * directly.  Normally, though, pi is set by supplying an NMRA
    * command to one of the _queue functions; iff the Nmra* is
-   * non-null, _queue will add an NMRA checksum and update pi.
+   * non-null, _queue will add an NMRA checksum (modifying *n)
+   * and update pi (which always results in a nonzero pi.l).
    */
 struct RetransmitRelaxedNode {
   PicInsn pi;
@@ -67,46 +70,47 @@ void retransmit_relaxed_cancel(RetransmitRelaxedNode *rn);
    * urgent_requeue if it's queued and has changed and must get a new
    * quota of urgency; _requeue is just _cancel followed by queue. */
 
-/*---------- features, filled in by record, used by features.c ----------*/
+/*---------- adjuncts, filled in by record, used by adjuncts.c ----------*/
 
-#define FEATURESADDR_TRANSMITS 4
+#define ADJUNCTSADDR_TRANSMITS 4
   /* 0..2 are func0to4 func5to8 func9to12 and speed cmd
    * pi.l is 0 if not transmitting */
 
-#define FEATS_SPEEDSTEP_BIT     0x4000u /* a->{current,all,permit}, f->bits */
-#define FEATS_SPEEDSTEP_REVERSE 0x8000u /* in a->all */
+#define ADJS_SPEEDSTEP_BIT     0x4000u /* a->{current,all,permit}, f->bits */
+#define ADJS_SPEEDSTEP_REVERSE 0x8000u /* in a->all */
 
-typedef struct FeaturesAddr {
-  struct FeaturesAddr *next;
+typedef struct AdjunctsAddr {
+  struct AdjunctsAddr *next;
   int addr, speedstep;
   unsigned current, permit, all;
-  RetransmitRelaxedNode rn[FEATURESADDR_TRANSMITS];
-} FeaturesAddr;
+  RetransmitRelaxedNode rn[ADJUNCTSADDR_TRANSMITS];
+} AdjunctsAddr;
 
 typedef struct {
   char *pname; /* first, for pname1st_compar */
-  FeaturesAddr *a;
+  AdjunctsAddr *a;
   unsigned bits; /* may have no or several bits set */
-} FeaturesFeature;
+} AdjunctsAdjunct;
 
-typedef struct FeaturesTarget {
+typedef struct AdjunctsTarget {
   char *pname; /* first, for pname1st_compar */
-  int n_feats;
-  FeaturesFeature *feats;
-} FeaturesTarget;
+  int n_adjs;
+  AdjunctsAdjunct *adjs;
+} AdjunctsTarget;
 
 extern int n_trains;
 extern Train *trains;
 extern Segment *segments;
 
-extern int n_feattargs, n_feataddrs;
-extern FeaturesTarget *feattargs;
-extern FeaturesAddr **feataddrs;
+extern int n_adjtargs, n_adjaddrs;
+extern AdjunctsTarget *adjtargs;
+extern AdjunctsAddr **adjaddrs;
 
 /*---------- global variables, in realtime.c ----------*/
 
 extern CommandInput cmdi;
 extern int picio_send_noise;
+extern int disable_watchdog;
 
 #define CIXF_U                 0x0000ffffu
 #define CIXF_FORCE             0x00010000u
@@ -154,6 +158,9 @@ void serial_transmit(const PicInsn *pi);
 void command_doline(ParseState *ps, CommandInput *cmdi_arg);
 const CmdInfo *current_cmd;
 
+void check_rusage_baseline(void);
+void check_rusage_check(int always_report);
+
 /*---------- for/from simulate.c ----------*/
 
 void serial_indata_process(int buf_used);
@@ -186,13 +193,14 @@ int picinsn_polarity_testbit(const PicInsn *pi, const SegmentInfo *segi);
   /* this belongs in {au,skel}proto-pic.[ch] really but it's
    * more convenient here. */
 
-void features_start_xmit(void);
-void features_updated(FeaturesAddr *a);
+void adjuncts_start_xmit(void);
+void adjuncts_updated(AdjunctsAddr *a);
 
 /*---------- from movpos.c ----------*/
 
 void points_turning_on(void);
 void motions_all_abandon(void);
+void movpos_reportall(void);
 
 /*---------- from eventhelp.c ----------*/
 
@@ -221,9 +229,10 @@ void toev_stop(TimeoutEvent*);    /* IR -> I */
 
 void realtime_priority(void);
 
-#define RTFEAT_DEFAULTS  0100u /* turns on MLOCK and SCHEDPRIO iff not sim */
+#define RTFEAT_DEFAULTS  0100u /* turns things on iff not sim */
 #define RTFEAT_MEM       0001u /* mlock */
 #define RTFEAT_CPU       0002u /* hard CPU scheduling priority */
+#define RTFEAT_RUSAGE    0004u /* check up on faults etc. in getrusage */
 
 #define RTFEAT_ALL_SHIFT 16
 #define RTFEAT_ALL(x) (RTFEAT_##x << RTFEAT_ALL_SHIFT)