This file is indexed.

/usr/include/rtai/rtai_sched.h is in librtai-dev 3.8.1-4build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
/*
 * Copyright (C) 1999-2008 Paolo Mantegazza <mantegazza@aero.polimi.it>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _RTAI_SCHED_H
#define _RTAI_SCHED_H

#include <rtai.h>
#ifndef __KERNEL__
#include <sys/time.h>
#include <time.h>
#include <errno.h>
#include <rtai_types.h>
#endif /* __KERNEL__ */

#define RT_SCHED_UP   1
#define RT_SCHED_SMP  2
#define RT_SCHED_MUP  3

#define RT_SCHED_HIGHEST_PRIORITY  0
#define RT_SCHED_LOWEST_PRIORITY   0x3fffFfff
#define RT_SCHED_LINUX_PRIORITY    0x7fffFfff

#define RT_RESEM_SUSPDEL  (-0x7fffFfff)

#define RT_SCHED_READY        1
#define RT_SCHED_SUSPENDED    2
#define RT_SCHED_DELAYED      4
#define RT_SCHED_SEMAPHORE    8
#define RT_SCHED_SEND        16
#define RT_SCHED_RECEIVE     32
#define RT_SCHED_RPC         64
#define RT_SCHED_RETURN     128
#define RT_SCHED_MBXSUSP    256
#define RT_SCHED_SFTRDY     512
#define RT_SCHED_POLL      1024
#define RT_SCHED_SIGSUSP    (1 << 15)

#define RT_RWLINV     (11)  // keep this the highest
#define RT_CHGPORTERR (10)
#define RT_CHGPORTOK  (9)
#define RT_NETIMOUT   (8)
#define RT_DEADLOK    (7)
#define RT_PERM       (6)
#define RT_OBJINV     (5)
#define RT_OBJREM     (4)
#define RT_TIMOUT     (3)
#define RT_UNBLKD     (2)
#define RT_TMROVRN    (1)  // keep this the lowest, must be 1
#define RTP_RWLINV     ((void *)RT_RWLINV)
#define RTP_CHGPORTERR ((void *)RT_CHGPORTERR)
#define RTP_CHGPORTOK  ((void *)RT_CHGPORTOK)
#define RTP_NETIMOUT   ((void *)RT_NETIMOUT)
#define RTP_DEADLOK    ((void *)RT_DEADLOK)
#define RTP_PERM       ((void *)RT_PERM)
#define RTP_OBJINV     ((void *)RT_OBJINV)
#define RTP_OBJREM     ((void *)RT_OBJREM)
#define RTP_TIMOUT     ((void *)RT_TIMOUT)
#define RTP_UNBLKD     ((void *)RT_UNBLKD)
#define RTP_TMROVRN    ((void *)RT_TMROVRN)
#define RTP_HIGERR     (RTP_RWLINV)
#define RTP_LOWERR     (RTP_TMROVRN)
#if CONFIG_RTAI_USE_NEWERR
#define RTE_BASE       (0x3FFFFF00)
#define RTE_RWLINV     (RTE_BASE + RT_RWLINV)
#define RTE_CHGPORTERR (RTE_BASE + RT_CHGPORTERR)
#define RTE_CHGPORTOK  (RTE_BASE + RT_CHGPORTOK)
#define RTE_NETIMOUT   (RTE_BASE + RT_NETIMOUT)
#define RTE_DEADLOK    (RTE_BASE + RT_DEADLOK)
#define RTE_PERM       (RTE_BASE + RT_PERM)
#define RTE_OBJINV     (RTE_BASE + RT_OBJINV)
#define RTE_OBJREM     (RTE_BASE + RT_OBJREM)
#define RTE_TIMOUT     (RTE_BASE + RT_TIMOUT)
#define RTE_UNBLKD     (RTE_BASE + RT_UNBLKD)
#define RTE_TMROVRN    (RTE_BASE + RT_TMROVRN)
#define RTE_HIGERR     (RTE_RWLINV)
#define RTE_LOWERR     (RTE_TMROVRN)
#else
#define RTE_BASE       (0xFFFB)
#define RTE_RWLINV     (RTE_BASE + RT_RWLINV)
#define RTE_CHGPORTERR (RTE_BASE + RT_CHGPORTERR)
#define RTE_CHGPORTOK  (RTE_BASE + RT_CHGPORTOK)
#define RTE_NETIMOUT   (RTE_BASE + RT_NETIMOUT)
#define RTE_DEADLOK    (RTE_BASE + RT_DEADLOK)
#define RTE_PERM       (RTE_BASE + RT_PERM)
#define RTE_OBJINV     (RTE_BASE + RT_OBJREM)
#define RTE_OBJREM     (RTE_BASE + RT_OBJREM)
#define RTE_TIMOUT     (RTE_BASE + RT_TIMOUT)
#define RTE_UNBLKD     (RTE_BASE + RT_UNBLKD)
#define RTE_TMROVRN    (RTE_BASE + RT_TMROVRN)
#define RTE_HIGERR     (RTE_RWLINV)
#define RTE_LOWERR     (RTE_TMROVRN)
#endif

#define RT_EINTR      (RTE_UNBLKD)

#define rt_is_reterr(i)  (i >= RTE_LOWERR)

#define RT_IRQ_TASK         0
#define RT_IRQ_TASKLET      1
#define RT_IRQ_TASK_ERR     0x7FFFFFFF

struct rt_task_struct;

typedef struct rt_task_info { 
	RTIME period; long base_priority, priority; 
} RT_TASK_INFO;

#ifdef __KERNEL__

#include <linux/time.h>
#include <linux/errno.h>

#if defined(CONFIG_RTAI_LONG_TIMED_LIST) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
#include <linux/rbtree.h>
typedef struct rb_node rb_node_t;
typedef struct rb_root rb_root_t;
#endif

#define RT_TASK_MAGIC 0x9ad25f6f  // nam2num("rttask")

#ifndef __cplusplus

#include <linux/sched.h>

typedef struct rt_queue {
	struct rt_queue *prev;
	struct rt_queue *next;
	struct rt_task_struct *task;
} QUEUE;

struct mcb_t {
	void *sbuf;
	int sbytes;
	void *rbuf;
	int rbytes;
};

/*Exit handler functions are called like C++ destructors in rt_task_delete().*/
typedef struct rt_ExitHandler {
	struct rt_ExitHandler *nxt;
	void (*fun) (void *arg1, int arg2);
	void *arg1;
	int   arg2;
} XHDL;

struct rt_heap_t { void *heap, *kadr, *uadr; };

#define RTAI_MAX_NAME_LENGTH  32

typedef struct rt_task_struct {
	long *stack __attribute__ ((__aligned__ (L1_CACHE_BYTES)));
	int uses_fpu;
	int magic;
	volatile int state, running;
	unsigned long runnable_on_cpus;
	long *stack_bottom;
	volatile int priority;
	int base_priority;
	int policy;
	int sched_lock_priority;
	struct rt_task_struct *prio_passed_to;
	RTIME period;
	RTIME resume_time;
	RTIME periodic_resume_time;
	RTIME yield_time;
	int rr_quantum, rr_remaining;
	int suspdepth;
	struct rt_queue queue;
	int owndres;
	struct rt_queue *blocked_on;
	struct rt_queue msg_queue;
	int tid;  /* trace ID */
	unsigned long msg;
	struct rt_queue ret_queue;
	void (*signal)(void);
	FPU_ENV fpu_reg __attribute__ ((__aligned__ (L1_CACHE_BYTES)));
	struct rt_task_struct *prev, *next;
	struct rt_task_struct *tprev, *tnext;
	struct rt_task_struct *rprev, *rnext;

	/* For calls from LINUX. */
	long *fun_args;
	long *bstack;
	struct task_struct *lnxtsk;
	long long retval;
	char *msg_buf[2];
	long max_msg_size[2];
	char task_name[RTAI_MAX_NAME_LENGTH];
	void *system_data_ptr;
	struct rt_task_struct *nextp, *prevp;

	RT_TRAP_HANDLER task_trap_handler[HAL_NR_FAULTS];

	long unblocked;
	void *rt_signals;
	volatile unsigned long pstate;
	unsigned long usp_flags;
	unsigned long usp_flags_mask;
	unsigned long force_soft;
	volatile int is_hard;

	long busy_time_align;
	void *linux_syscall_server;

	/* For use by watchdog. */
	int resync_frame;

	/* For use by exit handler functions. */
	XHDL *ExitHook;

	RTIME exectime[2];
	struct mcb_t mcb;

	/* Real time heaps. */
	struct rt_heap_t heap[2];

	volatile int scheduler;

#ifdef CONFIG_RTAI_LONG_TIMED_LIST
	rb_root_t rbr;
	rb_node_t rbn;
#endif
	struct rt_queue resq;
	unsigned long resumsg;
} RT_TASK __attribute__ ((__aligned__ (L1_CACHE_BYTES)));

#else /* __cplusplus */
extern "C" {
#endif /* !__cplusplus */

int rt_task_init(struct rt_task_struct *task,
		 void (*rt_thread)(long),
		 long data,
		 int stack_size,
		 int priority,
		 int uses_fpu,
		 void(*signal)(void));

int rt_task_init_cpuid(struct rt_task_struct *task,
		       void (*rt_thread)(long),
		       long data,
		       int stack_size,
		       int priority,
		       int uses_fpu,
		       void(*signal)(void),
		       unsigned run_on_cpu);

int rt_kthread_init(struct rt_task_struct *task,
		    void (*rt_thread)(long),
		    long data,
		    int stack_size,
		    int priority,
		    int uses_fpu,
		    void(*signal)(void));

int rt_kthread_init_cpuid(struct rt_task_struct *task,
		          void (*rt_thread)(long),
		          long data,
		          int stack_size,
		          int priority,
		          int uses_fpu,
		          void(*signal)(void),
		          unsigned run_on_cpu);

RTAI_SYSCALL_MODE void rt_set_runnable_on_cpus(struct rt_task_struct *task,
			     unsigned long cpu_mask);

RTAI_SYSCALL_MODE void rt_set_runnable_on_cpuid(struct rt_task_struct *task,
			      unsigned cpuid);

RTAI_SYSCALL_MODE void rt_set_sched_policy(struct rt_task_struct *task,
			 int policy,
			 int rr_quantum_ns);

int rt_task_delete(struct rt_task_struct *task);

int rt_get_task_state(struct rt_task_struct *task);

void rt_gettimeorig(RTIME time_orig[]);

int rt_get_timer_cpu(void);

int rt_is_hard_timer_running(void);

void rt_set_periodic_mode(void);

void rt_set_oneshot_mode(void);

RTAI_SYSCALL_MODE RTIME start_rt_timer(int period);

#define start_rt_timer_ns(period) start_rt_timer(nano2count((period)))

RTAI_SYSCALL_MODE void start_rt_apic_timers(struct apic_timer_setup_data *setup_mode,
			  unsigned rcvr_jiffies_cpuid);

void stop_rt_timer(void);

struct rt_task_struct *rt_whoami(void);

int rt_sched_type(void);

RTAI_SYSCALL_MODE int rt_task_signal_handler(struct rt_task_struct *task,
			   void (*handler)(void));

RTAI_SYSCALL_MODE int rt_task_use_fpu(struct rt_task_struct *task,
		    int use_fpu_flag);
  
void rt_linux_use_fpu(int use_fpu_flag);

RTAI_SYSCALL_MODE int rt_hard_timer_tick_count(void);

RTAI_SYSCALL_MODE int rt_hard_timer_tick_count_cpuid(int cpuid);

RTAI_SYSCALL_MODE RTIME count2nano(RTIME timercounts);

RTAI_SYSCALL_MODE RTIME nano2count(RTIME nanosecs);
  
RTAI_SYSCALL_MODE RTIME count2nano_cpuid(RTIME timercounts, unsigned cpuid);

RTAI_SYSCALL_MODE RTIME nano2count_cpuid(RTIME nanosecs, unsigned cpuid);
  
RTIME rt_get_time(void);

RTAI_SYSCALL_MODE RTIME rt_get_time_cpuid(unsigned cpuid);

RTIME rt_get_time_ns(void);

RTAI_SYSCALL_MODE RTIME rt_get_time_ns_cpuid(unsigned cpuid);

RTIME rt_get_cpu_time_ns(void);

RTIME rt_get_real_time(void);

RTIME rt_get_real_time_ns(void);

int rt_get_prio(struct rt_task_struct *task);

int rt_get_inher_prio(struct rt_task_struct *task);

RTAI_SYSCALL_MODE int rt_task_get_info(RT_TASK *task, RT_TASK_INFO *task_info);

RTAI_SYSCALL_MODE int rt_get_priorities(struct rt_task_struct *task, int *priority, int *base_priority);

RTAI_SYSCALL_MODE void rt_spv_RMS(int cpuid);

RTAI_SYSCALL_MODE int rt_change_prio(struct rt_task_struct *task,
		   int priority);

void rt_sched_lock(void);

void rt_sched_unlock(void);

void rt_task_yield(void);

RTAI_SYSCALL_MODE int rt_task_suspend(struct rt_task_struct *task);

RTAI_SYSCALL_MODE int rt_task_suspend_if(struct rt_task_struct *task);

RTAI_SYSCALL_MODE int rt_task_suspend_until(struct rt_task_struct *task, RTIME until);

RTAI_SYSCALL_MODE int rt_task_suspend_timed(struct rt_task_struct *task, RTIME delay);

RTAI_SYSCALL_MODE int rt_task_resume(struct rt_task_struct *task);

RTAI_SYSCALL_MODE int rt_set_linux_syscall_mode(long sync_async, void (*callback_fun)(long, long));

struct linux_syscalls_list;
void rt_exec_linux_syscall(RT_TASK *rt_current, struct linux_syscalls_list *syscalls, struct pt_regs *regs);

RTAI_SYSCALL_MODE void rt_return_linux_syscall(RT_TASK *task, unsigned long retval);

RTAI_SYSCALL_MODE int rt_irq_wait(unsigned irq);

RTAI_SYSCALL_MODE int rt_irq_wait_if(unsigned irq);

RTAI_SYSCALL_MODE int rt_irq_wait_until(unsigned irq, RTIME until);

RTAI_SYSCALL_MODE int rt_irq_wait_timed(unsigned irq, RTIME delay);

RTAI_SYSCALL_MODE void rt_irq_signal(unsigned irq);

RTAI_SYSCALL_MODE int rt_request_irq_task (unsigned irq, void *handler, int type, int affine2task);

RTAI_SYSCALL_MODE int rt_release_irq_task (unsigned irq);

RTAI_SYSCALL_MODE int rt_task_make_periodic_relative_ns(struct rt_task_struct *task,
				      RTIME start_delay,
				      RTIME period);

RTAI_SYSCALL_MODE int rt_task_make_periodic(struct rt_task_struct *task,
			  RTIME start_time,
			  RTIME period);

RTAI_SYSCALL_MODE void rt_task_set_resume_end_times(RTIME resume,
				  RTIME end);

RTAI_SYSCALL_MODE int rt_set_resume_time(struct rt_task_struct *task,
		       RTIME new_resume_time);

RTAI_SYSCALL_MODE int rt_set_period(struct rt_task_struct *task,
		  RTIME new_period);

int rt_task_wait_period(void);

void rt_schedule(void);

RTIME next_period(void);

RTAI_SYSCALL_MODE void rt_busy_sleep(int nanosecs);

RTAI_SYSCALL_MODE int rt_sleep(RTIME delay);

RTAI_SYSCALL_MODE int rt_sleep_until(RTIME time);

RTAI_SYSCALL_MODE int rt_task_masked_unblock(struct rt_task_struct *task, unsigned long mask);

#define rt_task_wakeup_sleeping(t)  rt_task_masked_unblock(t, RT_SCHED_DELAYED)

RTAI_SYSCALL_MODE struct rt_task_struct *rt_named_task_init(const char *task_name,
					  void (*thread)(long),
					  long data,
					  int stack_size,
					  int prio,
					  int uses_fpu,
					  void(*signal)(void));

RTAI_SYSCALL_MODE struct rt_task_struct *rt_named_task_init_cpuid(const char *task_name,
						void (*thread)(long),
						long data,
						int stack_size,
						int prio,
						int uses_fpu,
						void(*signal)(void),
						unsigned run_on_cpu);

RTAI_SYSCALL_MODE int rt_named_task_delete(struct rt_task_struct *task);

RT_TRAP_HANDLER rt_set_task_trap_handler(struct rt_task_struct *task,
					 unsigned vec,
					 RT_TRAP_HANDLER handler);

static inline RTIME timeval2count(struct timeval *t)
{
        return nano2count(t->tv_sec*1000000000LL + t->tv_usec*1000);
}

static inline void count2timeval(RTIME rt, struct timeval *t)
{
        t->tv_sec = rtai_ulldiv(count2nano(rt), 1000000000, (unsigned long *)&t->tv_usec);
        t->tv_usec /= 1000;
}

static inline RTIME timespec2count(const struct timespec *t)
{
        return nano2count(t->tv_sec*1000000000LL + t->tv_nsec);
}

static inline void count2timespec(RTIME rt, struct timespec *t)
{
        t->tv_sec = rtai_ulldiv(count2nano(rt), 1000000000, (unsigned long *)&t->tv_nsec);
}

static inline RTIME timespec2nanos(const struct timespec *t)
{
        return t->tv_sec*1000000000LL + t->tv_nsec;
}

static inline void nanos2timespec(RTIME rt, struct timespec *t)
{
        t->tv_sec = rtai_ulldiv(rt, 1000000000, (unsigned long *)&t->tv_nsec);
}

void rt_make_hard_real_time(RT_TASK *task);

void rt_make_soft_real_time(RT_TASK *task);

#ifdef __cplusplus
}
#else /* !__cplusplus */

/* FIXME: These calls should move to rtai_schedcore.h */

RT_TASK *rt_get_base_linux_task(RT_TASK **base_linux_task);

RT_TASK *rt_alloc_dynamic_task(void);

void rt_enq_ready_edf_task(RT_TASK *ready_task);

void rt_enq_ready_task(RT_TASK *ready_task);

int rt_renq_ready_task(RT_TASK *ready_task,
		       int priority);

void rt_rem_ready_task(RT_TASK *task);

void rt_rem_ready_current(RT_TASK *rt_current);

void rt_enq_timed_task(RT_TASK *timed_task);

void rt_rem_timed_task(RT_TASK *task);

void rt_dequeue_blocked(RT_TASK *task);

RT_TASK **rt_register_watchdog(RT_TASK *wdog,
			       int cpuid);

void rt_deregister_watchdog(RT_TASK *wdog,
			    int cpuid);

#endif /* __cplusplus */

#endif /* __KERNEL__ */

#if !defined(__KERNEL__) || defined(__cplusplus)

typedef struct rt_task_struct {
    int opaque;
} RT_TASK;

typedef struct QueueBlock {
    int opaque;
} QBLK;

typedef struct QueueHook {
    int opaque;
} QHOOK;

#endif /* !__KERNEL__ || __cplusplus */

#endif /* !_RTAI_SCHED_H */