rkfsn.h
40.7 KB
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
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
/*
* rkfsn.h
*
* Copyright 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
#ifndef __rkfsn_h_
#define __rkfsn_h_
#include <rkapi.h>
#ifdef __cplusplus
extern "C" {
#endif
/************************************************************************/
/*
** Application Manager defintions
*/
#define TV_NAME_SIZE 24
#define TV_MAX_ARGS 16
#ifndef _LANGUAGE_ASSEMBLY
typedef struct {
unsigned long hctID;
unsigned long bootTime;
unsigned long appInstance;
} TVSessionID;
typedef struct {
TVuchar count;
TVuchar why;
char* args[TV_MAX_ARGS];
} TVCommandLine;
typedef struct {
TVuchar argCount;
TVuchar why;
int helper;
int channel;
TVSessionID session;
} TVArgs;
typedef struct {
int secondsWest; /* of UTC */
int dst; /* is daylight savings time in effect */
} TVTimeZone;
typedef struct {
short cc;
short sap;
} TVAnalogOptions;
/* mask of down keys for auto-repeat mode */
typedef unsigned long long TVInputMask;
typedef union {
/*
* simple is used for the following app mgr messages
* terminate
* data ready (indirect from some resident app)
* application aborted (to the navigator)
* run channel (to the navigator)
*/
struct {
TVushort type;
TVushort func;
} simple;
struct {
TVushort type;
TVuchar changes;
TVuchar redrawInterval;
TVlong microseconds;
TVuchar framesSincePrevious;
} draw;
struct {
TVushort type;
TVuchar argCount;
TVuchar why;
int channel;
} restart;
struct {
TVushort type;
TVushort pad;
TVSessionID session;
} session; /* not currently used */
struct {
TVushort type;
TVushort channel;
TVushort status;
TVushort why;
} tuning;
struct {
TVushort type;
TVuchar direction;
TVuchar device;
int key;
TVInputMask mask;
TVTime time;
} input;
struct {
TVushort type;
TVushort pad;
TVlong id;
TVuchar service[TV_NAME_SIZE];
} createBookmark;
struct {
TVushort type;
TVuchar channel;
TVuchar blocked;
TVuchar notLoaded;
char name[TV_NAME_SIZE];
} applicationRun; /* sent only to navigator */
struct {
TVushort type;
TVushort panel;
TVlong x;
TVlong y;
} panel; /* sent only to navigator */
struct {
TVushort type;
TVushort pad;
int serial;
char attribute[TV_NAME_SIZE];
} userData; /* sent only to navigator */
struct {
TVushort type;
TVuchar length;
TVuchar piece;
TVuchar pieces;
char programName[TV_NAME_SIZE];
} programName; /* sent only to navigator */
struct {
TVushort type;
TVushort muted;
float volume;
} volume; /* sent only to navigator */
TVMessage notused; /* this is obsolete reference */
TVMessage msg;
} TVAppMgrMsg;
extern int tvGetPurchaseEnabled(void);
extern int tvNumericInput(int enabled);
/*
* For non-navigator applicaitons, the channel argument to
* RunApplication must be TV_ANY_CHANNEL. The transition field
* is ignored if the why in args is not TV_RUN_START.
*/
extern int tvRunApplication(
const TVCommandLine *cmd, int transition, int channel);
extern int tvRunHelper(const TVCommandLine *cmd);
extern int tvPushReturnCommand(const TVCommandLine *cmd, int terminate);
/*
* Each string in the returned command line from GetCommandLine should
* be freed to the global heap. Something like
* tvFree(cmd.args[i], strlen(cmd.args[i]) + 1)
* should work. Only do this for the arguments in [0..count).
*/
extern int tvGetCommandLine(TVCommandLine *cmd);
extern TVid tvGetHelperID(int helper);
extern int tvRunChannel(int channel);
extern int tvPromoteHelper(int helper, int transition);
extern int tvDestroyHelper(int helper);
extern int tvReturnFunction(void);
extern int tvSetCommandName(const char *name);
extern int tvWaitForPromote(const TVArgs* args);
extern int tvRegisterID(const char *name, TVid id, const short *caps);
extern int tvUnregisterID(const char *name);
extern int tvLookupID(const char *name, TVid *id);
extern int tvSetFuse(const char *propertyString, int length, TVTime time);
extern int tvApplicationAbort(void);
extern int tvOverlayRenderer(TVid id, int level, int cost);
extern int tvMainRenderer(TVid id, int redrawInterval);
extern int tvRedrawInterval(int redrawInterval);
extern int tvRemoveRenderer(TVid id);
extern int tvDoneRendering(void);
extern int tvHandleUserInput(TVid id);
extern int tvTuneAnalogChannel(int channel);
extern int tvSetAnalogOptions(const TVAnalogOptions *options);
extern int tvGetAnalogOptions(TVAnalogOptions *options);
extern int tvUsingAnalogVideo(void);
extern int tvGetTimeZone(TVTimeZone *tz);
extern int tvTunerFrequency(int tuner, int frequency);
extern int tvSetMpegAudioMixer(float volume);
extern int tvSetMacroVision(int on);
/*
* entry points passed through to the resident navigator
*/
extern int tvGetUserData(const char *attribute, char **value, int *length);
extern int tvOverlayProgramName(const char *name);
extern int tvPostPanel(int panel, int x, int y);
extern int tvDismissPanel(int panel);
/*
* entry points only callable by the resident navigator
*/
extern int tvCreateBookmark(long id, void *service, int length);
extern int tvGiveUserData(const char* value, int serial);
extern int tvGrabRemote(int on);
extern int tvShutDown(int reboot);
extern int tvSessionStart(void);
extern int tvSetAnalogVideoBypass(int on);
extern int tvSetChannelBlock(int channel, int blocked);
extern int tvSetPurchaseEnabled(int enabled);
extern int tvUserChange(void);
extern int tvWriteLEDs(const char* str);
extern int tvBlinkMessageLight(int on);
extern int tvSetWakeupTime(TVTime time);
/*
* entry points only callable by any resident app
*/
extern int tvDataReady(void);
/*
* provided by the application
*/
#ifdef TV_SETTOP
extern void main(const TVArgs*);
#endif
#endif /* _LANGUAGE_ASSEMBLY */
/* why apps get run or rerun */
#define TV_RUN_START 0
#define TV_RUN_BOOKMARK 1
#define TV_RUN_RETURN 2
#define TV_RUN_ALERT 3
/* special case for channel argument to running apps */
#define TV_ANY_CHANNEL -1
/* subtypes of terminate messages */
#define TV_TERMINATE_INITIAL 1
#define TV_TERMINATE_FINAL 2
#define TV_TERMINATE_RETURN 3
#define TV_TERMINATE_SHUTDOWN 4
#define TV_TERMINATE_INPUT_FULL 5
/* analog options values */
#define TV_ANALOG_OPTION_DEFAULT 0
#define TV_ANALOG_OPTION_ON 1
#define TV_ANALOG_OPTION_OFF 2
#define TV_ANALOG_OPTION_MIXED 3
/* overlay levels */
#define TV_OVERLAY_TRANSIENT_1 1
#define TV_OVERLAY_TRANSIENT_2 2
#define TV_OVERLAY_TRANSIENT_3 3
#define TV_OVERLAY_RESIDENT_1 11
#define TV_OVERLAY_RESIDENT_2 12
#define TV_OVERLAY_RESIDENT_3 13
/* Messages from the app manager (0x0001 to 0x007f) */
#define TV_MSG_DRAW 0x0001
#define TV_MSG_TERMINATE 0x0002
#define TV_MSG_INPUT 0x0003
#define TV_MSG_RESTART 0x0004
#define TV_MSG_PROMOTED 0x0005
#define TV_MSG_TUNING_STATUS 0x0006 /* also sent to navigator */
/* Messages forwarded from the navigator */
#define TV_MSG_DATA_READY 0x0010
#define TV_MSG_USER_CHANGE 0x0011
#define TV_MSG_NEW_SESSION 0x0012
#define TV_MSG_CREATE_BOOKMARK 0x0013
#define TV_MSG_NAVIGATOR 0x0014
/* Messages only sent to the resident navigator */
#define TV_MSG_APPLICATION 0x0040
#define TV_MSG_PROGRAM 0x0041
#define TV_MSG_USER_DATA 0x0042
#define TV_MSG_APPLICATION_ABORTED 0x0043
#define TV_MSG_POST_PANEL 0x0044
#define TV_MSG_RUN_RETURN 0x0045
#define TV_MSG_VOLUME 0x0046
#define TV_MSG_DISMISS_PANEL 0x0047
#define TV_MSG_RUN_CHANNEL 0x0048
/* last message 0x007f */
/* subtypes for panel messages to the resident navigator */
#define TV_PANEL_CHANNEL_BANNER 1
#define TV_PANEL_PIN_GATHER 2
#define TV_PANEL_ALPHA_GATHER 3
/* tuners that might have their frequency set */
#define TV_TUNER_FWD_APPLICATION 1
#define TV_TUNER_REV_APPLICATION 2
#define TV_TUNER_FWD_CONTROL 3
#define TV_TUNER_REV_CONTROL 4
/* values for device field of input messages */
#define TV_INPUT_REMOTE 1
#define TV_INPUT_PANEL 2
#define TV_INPUT_MOUSE 3
#define TV_INPUT_KEYBOARD 4
/* values for direction field in input messages */
#define TV_INPUT_PRESS 1
#define TV_INPUT_RELEASE 2
#define TV_INPUT_REPEAT 3
/* values for key field in input messages shared by all devices */
#define TV_INPUT_VOID 0xffffff
#define TV_INPUT_STOLEN 0xfffffe
#define TV_INPUT_RECOVERED 0xfffffd
/* values for the status field in tuning messages */
#define TV_ANALOG_ALLOWED 0
#define TV_ANALOG_FAILED 1
#define TV_ANALOG_WITHDRAWN 2
/* values for the why field in tuning messages */
#define TV_TUNING_OK 0
#define TV_TUNING_NOT_AUTH 3
#define TV_TUNING_NOT_AUTH_PPV 4
#define TV_TUNING_BOX_DISABLED 5
#define TV_TUNING_BOX_TIME_OUT 6
#define TV_TUNING_BOX_TAMPER 7
/* transition types supported by app mgr as part of RunApplication */
/* the various disjoint fields should be ORed together */
#define TV_TRANSITION_SYSTEM_DEFAULT 0x0000
#define TV_TRANSITION_NON_INTERLACED 0x0000
#define TV_TRANSITION_INTERLACED 0x0400
#define TV_TRANSITION_FADE 0x1000 /* Fade to gray. */
#define TV_TRANSITION_SNAP 0x2000 /* Go immediately to gray. */
#define TV_TRANSITION_NONE 0x3000 /* Keep last image around. */
#define TV_TRANSITION_WIPE_OFF 0x4000
#define TV_TRANSITION_SLIDE_OFF 0x5000
#define TV_TRANSITION_RIGHT 0x0001
#define TV_TRANSITION_LEFT 0x0002
#define TV_TRANSITION_UP 0x0004
#define TV_TRANSITION_DOWN 0x0008
#define TV_MAX_ENCRYPT_SIZE 1024
#define TV_MAX_USER_DATA_SIZE 500
#define TV_MAX_TOTAL_ARGS 300
/************************************************************************/
/*
* Centronics driver interfaces
*/
#ifndef _LANGUAGE_ASSEMBLY
typedef union TVCentMsgStr {
struct {
TVushort type;
TVushort reason;
TVuchar ctrl; /* parellel contorl register, see pi1.h */
TVuchar status; /* parellel status register */
TVuchar dmactrl; /* dma control register */
TVuchar intstat; /* interrupt status register */
TVuchar intmask; /* interrupt mask register */
} msg;
TVMessage notused;
} TVCentMsg;
typedef struct TVCentConfigStr {
int whoCares;
} TVCentConfig;
/* reasons for a message */
#define TV_CENT_STATUS 1
extern TVid tvOpenCent(TVid messages, const TVCentConfig* config);
extern int tvWriteCent(TVid port, const char* buffer, int buflen);
extern int tvCtrlCent(TVid port, int ctrl);
#endif /* _LANGUAGE_ASSEMBLY */
/************************************************************************/
/*
* exit to PROM (may force reboot depending on NVRAM variables
*/
#ifndef _LANGUAGE_ASSEMBLY
extern int tvProm(void);
typedef union TVControlPanelMsgStr {
struct {
TVushort type;
TVushort button;
} msg;
TVMessage notused;
} TVControlPanelMsg;
extern TVid tvOpenControlPanel(TVid messages);
extern int tvPowerOff(TVid cpanel);
extern int tvSupplyOff(void);
/* button numbers */
#define TV_CONTROL_PANEL_UP 0x01
#define TV_CONTROL_PANEL_DOWN 0x02
#define TV_CONTROL_PANEL_POWER 0x03
#endif /* _LANGUAGE_ASSEMBLY */
/************************************************************************/
/*
* Video input driver definitions
*/
#ifndef _LANGUAGE_ASSEMBLY
typedef union TVVideoInputMsgStr {
struct {
TVushort type;
TVushort buf; /* which buffer just arrived */
TVushort field; /* vino field counter value */
TVushort startField; /* starting field # */
} msg;
TVMessage notused;
} TVVideoInputMsg;
extern TVid tvOpenVideoInput(TVid messages, int flags, void** bufs);
extern int tvResetVideoInput(TVid vin);
extern int tvGetVideoInputFlags(TVid vin);
extern int tvSetVideoInputFlags(TVid vin, int newFlags);
#endif /* _LANGUAGE_ASSEMBLY */
/* Flags argument to tvOpenVideo/tvSetVideoFlags */
#define TV_VIDEO_INPUT_NTSC 0x0001
#define TV_VIDEO_INPUT_PAL 0x0001
#define TV_VIDEO_INPUT_SVIDEO 0x0002
#define TV_VIDEO_INPUT_GCAM 0x0003
#define TV_VIDEO_INPUT_AUTO 0x0004
#define TV_VIDEO_DECIMATE_NONE 0x0000
#define TV_VIDEO_DECIMATE_HALF 0x0010
#define TV_VIDEO_DECIMATE_THIRD 0x0020
#define TV_VIDEO_DECIMATE_QUARTER 0x0030
#define TV_VIDEO_DECIMATE_FIFTH 0x0040
#define TV_VIDEO_DECIMATE_SIXTH 0x0050
#define TV_VIDEO_DECIMATE_SEVENTH 0x0060
#define TV_VIDEO_DECIMATE_EIGHTH 0x0070
#define TV_VIDEO_ZERO_ALPHA 0x0080
/************************************************************************/
/*
* NG1 driver definitions
*/
#ifndef _LANGUAGE_ASSEMBLY
typedef union TVVerticalRetraceMessageStr {
struct {
TVushort type;
} msg;
TVMessage notused;
} TVVerticalRetraceMsg;
typedef struct TVGdmaRequestStr {
TVid region;
int offset;
TVushort lines;
TVushort width;
TVushort yzoom;
TVushort stride;
int flags;
void* from;
void* to;
int pattern;
} TVGdmaRequest;
extern int tvSetRetraceHandler(TVid where);
extern int tvSetTopscan(int newValue);
extern int tvGraphicsDma(TVGdmaRequest* request);
extern int tvGenLock(int which);
#endif /* _LANGUAGE_ASSEMBLY */
#define TV_NG1_DMA_TO_REX 0x00
#define TV_NG1_DMA_FROM_REX 0x01
#define TV_NG1_DMA_FILL 0x02
/* genlock flags */
#define TV_NG1_GENLOCK_OFF 0
#define TV_NG1_GENLOCK_VINO 1
#define TV_NG1_GENLOCK_MPEG 2
/************************************************************************/
/*
* Serial Port Driver Definitions
*/
#define TV_SERIAL_MSGBUFSIZE 27
#ifndef _LANGUAGE_ASSEMBLY
typedef union TVSerialMsgStr {
struct {
unsigned short type;
unsigned char port;
unsigned char reason;
unsigned char len;
unsigned char buf[TV_SERIAL_MSGBUFSIZE];
} msg;
TVMessage notused;
} TVSerialMsg;
/* configuration parameters */
typedef struct TVSerialConfigStr {
char baud;
char cflags;
} TVSerialConfig;
extern TVid tvOpenSerial(TVid pid, int port, int flags);
extern int tvWriteSerial(TVid sid, char *buf, int len);
extern int tvSetSerialConfig(TVid sid, TVSerialConfig *conf);
extern int tvGetSerialConfig(TVid sid, TVSerialConfig *conf);
#endif /* _LANGUAGE_ASSEMBLY */
#define TV_NUM_PORTS 2
#define TV_OTHER_PORT 0
#define TV_CONSOLE_PORT 1
/*
* flags to open, only one reader is allowed,
* but multiple writers are ok.
*/
#define TV_SERIAL_OPEN_READ 1
#define TV_SERIAL_OPEN_WRITE 2
#define TV_SERIAL_OPEN_EXCLUSIVE 4
/* reasons to get messages */
#define TV_SERIAL_READ_DATA 1
#define TV_SERIAL_BREAK_RCVD 2
/* baud rates */
#define TV_SERIAL_B50 1
#define TV_SERIAL_B75 2
#define TV_SERIAL_B110 3
#define TV_SERIAL_B134 4
#define TV_SERIAL_B150 5
#define TV_SERIAL_B200 6
#define TV_SERIAL_B300 7
#define TV_SERIAL_B600 8
#define TV_SERIAL_B1200 9
#define TV_SERIAL_B1800 10
#define TV_SERIAL_B2400 11
#define TV_SERIAL_B4800 12
#define TV_SERIAL_B9600 13
#define TV_SERIAL_B14400 14
#define TV_SERIAL_B19200 15
#define TV_SERIAL_B38400 16
#define TV_SERIAL_MAXBAUD TV_SERIAL_B38400
/* cflags */
#define TV_SERIAL_CSIZEMASK 0x3
#define TV_SERIAL_CSIZE5 0x0
#define TV_SERIAL_CSIZE6 0x1
#define TV_SERIAL_CSIZE7 0x2
#define TV_SERIAL_CSIZE8 0x3
#define TV_SERIAL_PARENB 0x4
#define TV_SERIAL_PARODD 0x8
#define TV_SERIAL_C1STOPB 0x10
#define TV_SERIAL_C2STOPB 0x00
/************************************************************************/
#ifndef _LANGUAGE_ASSEMBLY
typedef union TVAudioPortMsgStr {
struct {
TVushort type;
TVid port; /* which port */
TVulong size; /* amount of buffer that is r/w able */
} msg;
TVMessage notused;
} TVAudioPortMsg;
typedef struct TVAudioPortConfigStr {
long size; /* Size of the port buffer, in bytes */
unsigned int width : 1; /* Sample width: 8bits or 16bits */
unsigned int format : 1; /* Sample format: 2's complement or MPEG */
unsigned int channels : 1; /* Mono or stereo */
unsigned int device : 1; /* MPEG vs RAW */
unsigned int rw : 1; /* read or write */
unsigned int pad : 27;
unsigned short leftGain;
unsigned short rightGain;
} TVAudioPortConfig;
typedef struct TVAudioDeviceConfigStr {
short inputPorts; /* input ports currently available */
short outputPorts; /* output ports currently available */
short inputGainRight; /* input gain of right channel */
short inputGainLeft; /* input gain of left channel */
short outputAttenRight; /* output attenuation of right channel */
short outputAttenLeft; /* output attenuation of left channel */
int inputRate;
int outputRate;
int inputSource; /* line input or mic */
int mute; /* mute output */
} TVAudioDeviceConfig;
#define TV_ATTEN_MAX 0x1f /* 5 bits of attenuation */
extern TVid tvOpenAudioPort(TVid messages, TVAudioPortConfig *config);
extern int tvStartAudio(TVid port);
extern int tvStopAudio(TVid port);
extern int tvWriteSamples(TVid port, const char *buf, int buflen);
extern int tvReadSamples(TVid port, char *buf, int buflen);
extern int tvSetAudioConfig(TVid portID, const TVAudioPortConfig *config);
extern int tvGetAudioConfig(TVid portID, TVAudioPortConfig *config);
extern int tvSetAudioDevConfig(int device, const TVAudioDeviceConfig *config);
extern int tvGetAudioDevConfig(int device, TVAudioDeviceConfig *config);
#endif /* _LANGUAGE_ASSEMBLY */
/* Values for port config */
#define TV_AUDIO_16BIT 0x0
#define TV_AUDIO_8BIT 0x1
#define TV_AUDIO_2COMP_FORMAT 0x0
#define TV_AUDIO_MPEG_FORMAT 0x1
#define TV_AUDIO_MONO 0x0
#define TV_AUDIO_STEREO 0x1
#define TV_AUDIO_RAW_DEVICE 0x0
#define TV_AUDIO_MPEG_DEVICE 0x1
#define TV_AUDIO_WRITE 0x0
#define TV_AUDIO_READ 0x1
/* input/output rates */
#define TV_AUDIO_44100_RATE 0x0
#define TV_AUDIO_22050_RATE 0x1
#define TV_AUDIO_11025_RATE 0x2
/* input source */
#define TV_AUDIO_MIC_INPUT 0x0
#define TV_AUDIO_LINE_INPUT 0x1
/************************************************************************/
/*
** Statistics driver. Allows caller access to kernel statitics memory.
** The caller creates a physical region and maps it at a virtual address
** that is aligned on the SHARE_ALIGNMENT boundary. After that the caller
** can poll the values to do whatever it wants with them. To atomically
** clear the stats use the tvResetStats call.
*/
#ifndef _LANGUAGE_ASSEMBLY
struct __TVStatsStr;
extern TVid tvOpenStats(struct __TVStatsStr** paddr, int* size);
extern int tvResetStats(TVid stats);
#endif /* _LANGUAGE_ASSEMBLY */
/************************************************************************/
#ifndef _LANGUAGE_ASSEMBLY
/*
* message from driver
*/
typedef union TVAdecMsg {
TVMessage msg;
struct {
TVushort type; /* message type */
TVushort why; /* message subtype */
TVid id; /* buffer queue id */
TVulong info; /* info bits */
TVushort sfreq; /* sampling frequency */
TVuchar dmph; /* deemphasis */
TVuchar sync; /* sync status */
TVulong anc; /* ancillary data */
TVuchar nanc; /* nbr of bits of ancillary data */
} adec;
struct {
TVushort type; /* message type */
TVushort why; /* message subtype */
TVid id; /* buffer queue id */
TVulong cookie; /* sync marker found */
TVTime time; /* time that the cookie was found */
TVuchar cnt; /* number of bits in the sync marker */
} sync;
struct {
TVushort type; /* message type */
TVushort why; /* message subtype */
TVid id; /* buffer queue id */
TVushort level; /* buffer level when pts was found */
TVTime time; /* time that the pts was found */
TVuchar pts[5]; /* PTS value */
} pts;
} __TVAdecMsg;
/*
* configuration
*/
typedef struct {
unsigned char mode; /* decoder mode */
unsigned char flags; /* flags */
unsigned char layer; /* MPEG layer mode (only MPEG mode) */
unsigned char audid; /* audio stream ID (only MPEG mode) */
unsigned short sfreq; /* sampling frequency (only bypass mode) */
unsigned short kbstart; /* kbytes in buffer before start */
unsigned int infomask; /* info msg mask bits */
unsigned short dmph; /* deemphasis */
} __TVAdecConf;
typedef struct {
unsigned short sfreq;
unsigned short level;
unsigned short maxlevel;
unsigned char pts[5];
} TVAdecInfo;
extern TVid tvOpenAdec(TVid fillid, TVid infoid, __TVAdecConf *conf);
extern int tvWriteAdec(TVid id, TVid buf);
extern int tvCtrlAdec(TVid id, int cmd, void *arg);
#endif /* _LANGUAGE_ASSEMBLY */
/* why */
#define TV_MSG_ADEC_INFO 0
#define TV_MSG_ADEC_SYNC 1
#define TV_MSG_ADEC_PTS 2
/* mode */
#define __TV_ADEC_MPEG 1 /* MPEG mode */
#define __TV_ADEC_BYPASS 2 /* audio bypass */
/* flags */
#define __TV_ADEC_ID_ENABLE 0x01 /* audio ID enable */
#define __TV_ADEC_CHK_CRC 0x02 /* enable CRC checking */
#define __TV_ADEC_START_BY_CMD 0x04 /* use start command to start */
#define __TV_ADEC_MUTE_ON_UNDER 0x08 /* mute on underflow */
#define __TV_ADEC_NO_BUF_READY 0x10 /* no buffer ready messages */
#define __TV_ADEC_NO_BUF_DONE 0x20 /* no buffer done messages */
/* layer */
#define __TV_ADEC_MPEG_AUDIO 0 /* MPEG audio stream */
#define __TV_ADEC_MPEG_PACKET 1 /* MPEG packet stream */
#define __TV_ADEC_MPEG_SYSTEM 2 /* MPEG system stream */
/* sampling frequencies */
#define __TV_ADEC_SF_44100 0x00 /* 44.1 khz */
#define __TV_ADEC_SF_48000 0x01 /* 48 khz */
#define __TV_ADEC_SF_32000 0x02 /* 32 khz */
/* deemphasis */
#define __TV_ADEC_DMPH_NONE 0x00 /* none */
#define __TV_ADEC_DMPH_50_15 0x01 /* 50/15 micro seconds */
#define __TV_ADEC_DMPH_CCITT 0x03 /* CCITT J.17 */
/* info msg bits */
#define __TV_ADEC_INFO_EOS 0x1000 /* EOS (end of stream) */
#define __TV_ADEC_INFO_DMPH 0x0400 /* deemphasis changed */
#define __TV_ADEC_INFO_SFREQ 0x0200 /* sampling frequency changed */
#define __TV_ADEC_INFO_UNDER 0x0100 /* PCM output underflow */
#define __TV_ADEC_INFO_ANC 0x0040 /* ancillary data */
#define __TV_ADEC_INFO_CRC 0x0020 /* CRC error detected */
#define __TV_ADEC_INFO_PTS 0x0004 /* PTS */
#define __TV_ADEC_INFO_HDR 0x0002 /* valid header detected */
#define __TV_ADEC_INFO_SYNC 0x0001 /* sync status changed */
/* sync state */
#define __TV_ADEC_SYNC_UNLOCK 0x00 /* unlocked */
#define __TV_ADEC_SYNC_RECOVER 0x02 /* attempting to recover */
#define __TV_ADEC_SYNC_LOCKED 0x03 /* locked */
/* control commands */
#define __TV_ADEC_CMD_RESTART 0 /* restart decoder */
#define __TV_ADEC_CMD_START 1 /* start decoder */
#define __TV_ADEC_CMD_STOP 2 /* stop decoder */
#define __TV_ADEC_CMD_MUTE 3 /* mute decoder (still decoding) */
#define __TV_ADEC_CMD_SKIP 4 /* skip audio frame */
#define __TV_ADEC_CMD_REPEAT 5 /* repeat audio frame */
#define __TV_ADEC_CMD_PAUSE 6 /* pause playing */
#define __TV_ADEC_STATUS_FRAMES 7 /* return frame count */
#define __TV_ADEC_STATUS_BUFFER 8 /* return input buffer size */
#define __TV_ADEC_CMD_SEEK 9 /* look for token in data stream */
#define __TV_ADEC_STATUS 10 /* return status structure */
/************************************************************************/
#ifndef _LANGUAGE_ASSEMBLY
/*
* message from SA driver
*/
typedef union {
TVMessage msg;
struct {
TVushort type; /* message type */
TVushort flag; /* flags for message values */
TVulong val; /* diagnostic bits, DLP or PLCP status */
} sa;
} TVSaMsg;
extern TVid tvOpenSa(TVid id, unsigned int flags);
extern int tvCtrlSa(TVid id, unsigned int cmd, void *arg);
/*
* status/statistics structure
*/
typedef struct {
unsigned char rmaj; /* major revision nbr */
unsigned char rmin; /* minor revision nbr */
unsigned char txl_rac; /* tx level of rev appl channel */
unsigned char txl_rcc; /* tx level of rev ctrl channel */
unsigned char vol_adec; /* adec volume */
unsigned char vol_btsc; /* BTSC volume */
unsigned char amux; /* status of audio switch */
unsigned char video; /* video modes */
unsigned char cc; /* closed-caption status 0=off, 1=on */
unsigned int e_fac; /* accumulated errors of fac */
unsigned int e_fcc; /* accumulated errors of fcc */
unsigned int e_rac; /* accumulated errors of rac */
unsigned int e_rcc; /* accumulated errors of rcc */
} TVSaStat;
/*
* frequencies
*/
typedef struct {
unsigned int f_fac; /* frequency of fwd appl channel */
unsigned int f_fcc; /* frequency of fwd ctrl channel */
unsigned int f_rac; /* frequency of rev appl channel */
unsigned int f_rcc; /* frequency of rev ctrl channel */
unsigned int fcc_fmtrap; /* status of fcc FM trap */
} TVSaFreq;
extern int tvStatSa(TVSaStat *stp, TVSaFreq *freqp);
#endif /* _LANGUAGE_ASSEMBLY */
/*
* flags of TVSaMsg.sa.flag
*/
#define TV_SAMF_DIAG 1 /* diagnostic message */
#define TV_SAMF_DLP 2 /* DLP status message */
#define TV_SAMF_PLCP 3 /* PLCP status message */
#define TV_SAMF_MASK 0x00ff
#define TV_SAMF_CSERR 0x8000 /* checksum error in response */
/*
* flags to tvOpenSa()
*/
#define TV_SAF_FORCE_TUNE_FAC 0x0001 /* force re-tuning on fac */
#define TV_SAF_FORCE_TUNE_FCC 0x0002 /* force re-tuning on fcc */
#define TV_SAF_FORCE_TUNE_RAC 0x0004 /* force re-tuning on rac */
#define TV_SAF_FORCE_TUNE_RCC 0x0008 /* force re-tuning on rcc */
/*
* commands to tvCtrlSa()
* The first range of numbers specify commands which have
* a ctrl-micro transaction associated with them.
* The second range is for driver commands.
*/
#define TV_SA_CMD_SET_ADEC_VOL 0 /* set adec volume, ctrl */
#define TV_SA_CMD_SET_AMUX 1 /* set audio muxes */
#define TV_SA_CMD_SET_BTSC 2 /* set BTSC decoder */
#define TV_SA_CMD_QRY_BTSC 3 /* query BTSC decoder */
#define TV_SA_CMD_SET_VIDEO 4 /* set video modes */
#define TV_SA_CMD_MACROVISION 5 /* set macrovision */
#define TV_SA_CMD_TUNE_FAC 8 /* tune fwd-appl channel */
#define TV_SA_CMD_TUNE_FCC 9 /* tune fwd-ctrl channel */
#define TV_SA_CMD_TUNE_RAC 10 /* tune rev-appl channel */
#define TV_SA_CMD_TUNE_RCC 11 /* tune rev-ctrl channel */
#define TV_SA_CMD_LOCK_QAM 12 /* lock QAM chip-set */
#define TV_SA_CMD_DLP_STATUS 13 /* read DLP status */
#define TV_SA_CMD_PLCP_STATUS 14 /* read PLCP status */
#define TV_SA_CMD_MAX 24 /* # of commands */
/* fmtrap values for TV_SA_CMD_TUNE_FCC */
#define TV_FCC_FMTRAP_OFF 0 /* FCC FM trap off */
#define TV_FCC_FMTRAP_ON 1 /* FCC FM trap on */
/* DAC volume control */
#define TV_ADAC_VOL_MIN 0 /* smallest volume */
#define TV_ADAC_VOL_MAX 120 /* maximum volume */
#define TV_ADAC_SET_VOLUME 0x01 /* accept volume */
#define TV_ADAC_SET_MUTE 0x04 /* accept mute */
#define TV_ADAC_SET_FULLSCALE 0x08 /* accept full scale */
#define TV_ADAC_MUTE 0x40 /* save volume and mute */
#define TV_ADAC_FULLSCALE 0x80 /* drive volume to full scale */
/* audio muxes */
#define TV_AMUX_BTSC_TO_SGI 0 /* BTSC --> SGI input */
#define TV_AMUX_ADEC_TO_SGI 0x01 /* adec --> SGI input */
#define TV_AMUX_ADEC_OUT 0 /* adec --> HCT output */
#define TV_AMUX_SGI_OUT 0x02 /* SGI --> HCT output */
#define TV_AMUX_MASK 0x03 /* mask above bits */
/* BTSC volume and mode */
#define TV_BTSC_VOL_MIN 0 /* smallest volume */
#define TV_BTSC_VOL_MAX 84 /* maximum volume */
#define TV_BTSC_SET_VOLUME 0x01 /* accept volume */
#define TV_BTSC_SET_SAP 0x02 /* accept SAP */
#define TV_BTSC_SET_MUTE 0x04 /* accept mute */
#define TV_BTSC_SET_STEREO 0x08 /* accept stereo */
#define TV_BTSC_SAP 0x20 /* SAP (second audio program) mode */
#define TV_BTSC_MUTE 0x40 /* save volume and mute */
#define TV_BTSC_STEREO 0x80 /* stereo bit */
/* BTSC query bits */
#define TV_BTSC_IS_STEREO 0x01 /* stereo available */
#define TV_BTSC_IS_SAP 0x02 /* SAP available */
#define TV_BTSC_SAP_BIT 0x20 /* copy of SAP bit */
#define TV_BTSC_IS_MUTE 0x40 /* mute is on */
/* video modes */
#define TV_VIDEO_SET_MUX 0x01 /* enable change of video mux */
#define TV_VIDEO_SET_MOD_CH 0x02 /* enable change of RF channel */
#define TV_VIDEO_SET_RF_BYPASS 0x04 /* enable change of RF bypass */
#define TV_VIDEO_SET_AC_RELAY 0x08 /* enable change of AC relay */
#define TV_VIDEO_MUX_DIGITAL 0 /* video mux digital (NG1) */
#define TV_VIDEO_MUX_ANALOG 0x10 /* video mux analog */
#define TV_VIDEO_MOD_CH3 0 /* RF channel 3 */
#define TV_VIDEO_MOD_CH4 0x20 /* RF channel 4 */
#define TV_VIDEO_RF_BYPASS_OFF 0 /* RF bypass off */
#define TV_VIDEO_RF_BYPASS_ON 0x40 /* RF bypass on */
#define TV_VIDEO_AC_RELAY_OFF 0 /* AC relay off */
#define TV_VIDEO_AC_RELAY_ON 0x80 /* AC relay on */
/* status bits returned from tuners */
#define TV_TUNER_LOCKED 0x01 /* tuner is locked */
#define TV_TUNER_FM_TRAP_ON 0x02 /* FM trap on (only on FCC) */
/* DLP status bits */
#define TV_DLP_AHA_IN_FAULT 0x40 /* AHA input fault */
#define TV_DLP_AHA_OUT_FAULT 0x20 /* AHA output fault */
#define TV_DLP_DI_INC_FAULT 0x10 /* deinterleave increment fault */
#define TV_DLP_DI_ADDR_FAULT 0x08 /* deinterleave address fault */
#define TV_DLP_FRAME_SYNC_FND 0x04 /* frame sync found */
#define TV_DLP_FRAME_SYNC_LOST 0x02 /* frame sync lost */
#define TV_DLP_FRAME_SYNC 0x01 /* frame sync */
/*
* function of the driver lib
*/
#ifndef _LANGUAGE_ASSEMBLY
extern int tvSaSetAdecVol(TVid id, unsigned int vol, unsigned int ctrl);
extern int tvSaSetAmux(TVid id, unsigned int amux);
extern int tvSaSetBtsc(TVid id, unsigned int vol, unsigned int ctrl);
extern int tvSaQueryBtsc(TVid id);
extern int tvSaSetVideo(TVid id, unsigned int vmode);
extern int tvSaTuneFac(TVid id, unsigned int freq);
extern int tvSaTuneFcc(TVid id, unsigned int freq, unsigned int fmtrap);
extern int tvSaTuneRac(TVid id, unsigned int freq);
extern int tvSaTuneRcc(TVid id, unsigned int freq);
extern int tvSaLockQam(TVid id, unsigned int how);
extern int tvSaRdDlpStatus(TVid id);
extern int tvSaRdPlcpStatus(TVid id);
#endif /* ! _LANGUAGE_ASSEMBLY */
/************************************************************************/
#ifndef _LANGUAGE_ASSEMBLY
/*
* message from closed-caption driver
* TV_CC_MAX must be changed to the max sent by the ctrl-micro.
*/
#define TV_CC_MAX (sizeof(TVMessage) - 4)
typedef union {
TVMessage msg;
struct {
TVushort type; /* message type */
TVuchar flag; /* flags for message */
TVuchar size; /* # of bytes in msg */
TVuchar msg[TV_CC_MAX]; /* closed-caption data */
} cc;
} TVCcMsg;
/* flags */
#define TV_CC_OK 0 /* checksum data ok */
#define TV_CC_BAD_CHKSUM 0x01 /* bad checksum of cc data */
#define TV_CC_TOO_BIG 0x02 /* too many cc data */
/*
* message from ctrl-micro about BTSC/SAP status
*/
typedef union {
TVMessage msg;
struct {
TVushort type; /* message type */
TVushort btsc; /* BTSC/SAP status (see TV_ATV_IS_...) */
} btsc;
} TVBtscMsg;
extern TVid tvOpenAtv(TVid id);
extern int tvCtrlAtv(TVid id, unsigned int cmd, void *arg);
/* ATV lib */
extern int tvAtvCcOn(TVid id);
extern int tvAtvCcOff(TVid id);
extern int tvAtvGetBtsc(TVid id);
extern int tvAtvSetBtsc(TVid id, unsigned int mode);
#endif /* _LANGUAGE_ASSEMBLY */
/* status returned from tvAtvGetBtsc() */
#define TV_ATV_IS_MONO 0 /* mono signal */
#define TV_ATV_IS_STEREO 1 /* stereo signal */
#define TV_ATV_IS_SAP 2 /* mono/SAP signal */
/* modes for tvAtvSetBtsc() */
#define TV_ATV_BTSC_MONO 0 /* want mono on left/right */
#define TV_ATV_BTSC_STEREO 1 /* left/right */
#define TV_ATV_BTSC_SAP 2 /* want SAP on left/right */
#define TV_ATV_BTSC_MIXED 3 /* left=mono, right=SAP */
/* commands to tvCtrlAtv() */
#define TV_ATV_CC 0 /* closed-caption on/off */
#define TV_ATV_GET_BTSC 1 /* query BTSC status (stereo/SAP) */
#define TV_ATV_SET_BTSC 2 /* set BTSC mode (stereo/SAP) */
#define TV_ATV_MAX 3 /* # of atv control functions */
/* flags to tvCtrlAtv(TV_ATV_CC) */
#define TV_CC_OFF 0 /* closed-caption off */
#define TV_CC_ON 1 /* closed-caption on */
/************************************************************************/
#ifndef _LANGUAGE_ASSEMBLY
/*
* VCXO driver
*/
typedef struct {
unsigned int mod300; /* modulo 300 counter (9 bits) */
unsigned long h24[2]; /* 24 hour cnt (33 bits, upper/lower) */
} TVMpegCnt;
extern TVid tvOpenVcxo(void);
extern int tvSetVcxo(TVid id, unsigned int val);
extern int tvSetMpegCnt(TVid id, TVMpegCnt *cntp);
extern int tvGetMpegCnt(TVid id, TVMpegCnt *cntp);
#endif /* _LANGUAGE_ASSEMBLY */
#define TV_VCXO_MASK 0x0fff /* lower 12-bits are used */
/************************************************************************/
/*
* expected priority levels
*/
#define TV_PRI_IDLE 0
#define TV_PRI_BACKGROUND_1 1
#define TV_PRI_BACKGROUND_2 2
#define TV_PRI_BACKGROUND_3 3
#define TV_PRI_PRINTER 4
#define TV_PRI_TRAPS 5
/* 6-9 for apps */
#define TV_PRI_DOWNLOAD 10 /* for getting assets */
#define TV_PRI_BLENDER 13
/* 14-18for apps (higher than blender) */
#define TV_PRI_AUDIO 19
#define TV_PRI_NETWORK 24 /* for use by kernel */
#define TV_PRI_APP_MAIN 27
#define TV_PRI_RES_NAV_MAIN 28 /* also some threads in AppMgr */
#define TV_PRI_TIMED 29
#define TV_PRI_REAPER 31
/************************************************************************/
#if !defined(_LANGUAGE_ASSEMBLY) && !defined(KERNEL)
/*
* Make a new thread, and create a default sized stack region (8k). This
* insures that the various machine dependent registers are correctly
* setup. This also makes sure that if the thread function returns that
* the thread is destroyed.
*/
typedef struct {
TVid threadID;
TVid regionID;
} TVThreadHandle;
extern int tvMakeThread(void (*pfn)(void *), void *arg,
int priority, TVThreadHandle *threadHandle);
extern int tvDestroyThread(TVThreadHandle *threadHandle);
/*
* Helper function used by tvMakeThread to start a new thread. The stack
* for the new thread is initialized such that:
* 4(sp) is the gp value to use
* 8(sp) is the address of the real procedure to start running
* 12(sp) is the TVid of the stack region created
*/
extern void tvBeginThread(void* arg);
#define __TV_ROUND_BYTES_TO_PAGES(bytes) \
(((bytes) + TV_PAGE_SIZE - 1) >> TV_PAGE_SHIFT)
#define __TV_PAGES_TO_BYTES(pages) \
((pages) << TV_PAGE_SHIFT)
/************************************************************************/
/* Definitions for heap */
#define __TV_MALLOC_ALIGN_LOG2 3
#define __TV_MALLOC_ALIGN (1 << __TV_MALLOC_ALIGN_LOG2)
#define __TV_MAX_SMALL_ALLOC_SIZE 2048
#define __TV_MAX_SMALL_ALLOC_UNITS \
(__TV_MAX_SMALL_ALLOC_SIZE >> __TV_MALLOC_ALIGN_LOG2)
#define __TV_MAX_BIG_ALLOC_SIZE 0x200000
#define __TV_MAX_BIG_ALLOC_UNITS (__TV_MAX_BIG_ALLOC_SIZE >> TV_PAGE_SHIFT)
typedef int (*TVHeapFunc)(TVid region, int alignment);
typedef struct __TVHeapStr {
char *base;
char *limit;
char *current;
char *freeLists[__TV_MAX_SMALL_ALLOC_UNITS];
char *bigFreeList[__TV_MAX_BIG_ALLOC_UNITS];
TVid region;
TVid lock;
TVHeapFunc morecore;
} TVHeap;
#define TV_HEADER_SIZE \
(sizeof(TVHeap) + (TV_REGION_ALIGNMENT - 1) & \
~(TV_REGION_ALIGNMENT - 1))
extern void *tvAlloc(unsigned int size);
extern void *tvRegionAlloc(unsigned int size);
extern void *tvHeapAlloc(TVHeap *hp, unsigned int size);
extern void tvHeapFree(TVHeap *hp, void *p, unsigned int size);
extern void tvFree(void *vaddr, unsigned int size);
extern TVHeap *tvHeapFromVaddr(void *vaddr);
extern TVHeap *tvHeapInit(unsigned int size, TVHeapFunc morecode,
TVid region, void *vaddr);
extern void tvHeapDestroy(TVHeap *hp);
extern int tvGetRegion(unsigned int sz, int flags, TVid *region, void **vaddr);
extern TVid tvFindRegion(void* vaddr, int* offset);
/************************************************************************/
/*
* For leak detection
*/
/*
* printStatistics != 0 => print Allocation table
*
* tvReportUnfreedBlocks() reports unfreed blocks since last
* tvMarkAllocBlocks()/tvReportUnfreedBlocks()/tvReportAllUnfreedBlocks()
*
* tvReportAllUnfreedBlocks() always reports all unfreed blocks since
* the beginning of execution.
*/
extern void tvMarkAllocBlocks(int printStatistics);
extern void tvReportAllUnfreedBlocks(int printStatistics);
extern void tvReportUnfreedBlocks(int printStatistics);
extern void tvPrintAllocationTable(void);
/************************************************************************/
/*
* Locking functions
*/
extern int tvCasI(int *addr, int oldValue, int newValue);
#endif /* !defined(_LANGUAGE_ASSEMBLY) && !defined(KERNEL) */
/************************************************************************/
/*
* ATM Syscall interface
*/
/* flag in tvOpenAtm */
#define __TV_ATM_RD 0x1 /* READ open */
#define __TV_ATM_WR 0x2 /* WRITE open */
/* service in tvOpenAtm */
#define __TV_ATM_FWD_APPLICATION_SHARED 0
#define __TV_ATM_FWD_APPLICATION_EXCLUSIVE 1
#define __TV_ATM_FWD_CONTROL 2
#define __TV_ATM_REV_APPLICATION 3
#define __TV_ATM_REV_CONTROL 4
/* cmd in tvSetAtm() */
#define __TV_ATM_STOP 0x1 /* stop the interface (arg == 0) */
#define __TV_ATM_START 0x2 /* start the interface (arg == 0) */
#define __TV_ATM_SHIW 0x4 /* set HIWATER mark for interface arg == int */
/* cmd in tvGetAtm() */
#define __TV_ATM_GETCOUNTERS 0x5 /* get the atm counters */
#define __TV_ATM_GETVCCSTATS 0x6 /* get atm VCC statistics */
#define __TV_ATM_MAXPCK (12*1024-8) /* max packet size for tvWriteAtm() */
#if !defined(_LANGUAGE_ASSEMBLY)
extern TVid tvOpenAtm(int vpi, int vci, int service, int flag);
extern int tvReadAtm(TVid id, char *buf, unsigned int ulen);
extern int tvWriteAtm(TVid id, char *buf, unsigned int ulen);
extern int tvSetAtm(TVid atmid, int cmd, void *arg);
extern int tvGetAtm(TVid atmid, int cmd, void *arg);
extern TVid tvDrainAtm(TVid atmid, int* lenp);
#define __TV_ATM_COUNTERS 12
typedef unsigned long atmCounter[__TV_ATM_COUNTERS];
#endif
/************************************************************************/
/*
* Thread usage system call interface.
*/
#define TV_THREAD_USER 0
#define TV_THREAD_STOPPED 1
#define TV_THREAD_RUNNABLE 2
#define TV_THREAD_SYSTEM 3
#define TV_THREAD_SLEEPING 4
#define TV_THREAD_RCV_WAIT 5
#define TV_THREAD_LOCK_WAIT 6
#define TV_THREAD_INTR_WAIT 7
#define TV_THREAD_ZOMBIE 9
#define TV_THREAD_STATES_NUMBER 10
#ifndef _LANGUAGE_ASSEMBLY
typedef struct TVThreadUsageStr {
TVTime states[TV_THREAD_STATES_NUMBER];
} TVThreadUsage;
extern int tvGetThreadUsage(TVid tid, TVThreadUsage *usage);
#endif /* _LANGUAGE_ASSEMBLY */
/* Crash Dump Call */
#ifndef _LANGUAGE_ASSEMBLY
extern int tvReadCrash(TVid id, char *buf, int len);
#endif /* _LANGUAGE_ASSEMBLY */
#define TV_CRASH_DUMP_SIZE 4096
/************************************************************************/
/*
* Profiling system call interface.
*/
#define TV_PROF_USHORT 1
#define TV_PROF_UINT 2
/* sanity check on the number profiled regions */
#define TV_PROF_MAXN 10
#ifndef _LANGUAGE_ASSEMBLY
typedef struct TVProfStr {
void *base;
TVulong size;
TVulong offset;
TVulong scale;
} TVProf;
extern int tvProfile(TVProf *profp, int profcnt, TVTime *tsp,
unsigned int flags);
/************************************************************************/
/*
* NVRAM functions
*/
extern int tvGetNv(char *var, char *buf, int szbuf);
extern int tvSetNv(char *var, char *val);
/************************************************************************/
/*
* Retreive the configuration
*/
#define __TV_ATM_CONF 0x1
#define __TV_AV_CONF 0x2
#define __TV_AV_NO_MIXER 0x4
#define __TV_HAVE_DEBUGGER 0x8
extern TVulong __tvGetConfig(void);
/************************************************************************/
/*
* Control flags used byt tvLogControl
*/
#define TV_LOG_ENABLE (1) /* enable logging */
#define TV_LOG_DISABLE (2) /* disable logging */
#define TV_LOG_CLEAR_BUFFER (3) /* clear buffer */
#define TV_LOG_RESET (4) /* clear buffer adn mask, disable logging */
extern int tvLogControl(int flag);
/*
* Set/Clear Log mask from userland
*/
extern int tvLogSetMask(int firstCode, int lastCode);
extern int tvLogClearMask(int firstCode, int lastCode);
extern int tvLogReadBuffer(char *buf, int *len);
/************************************************************************/
#endif /* _LANGUAGE_ASSEMBLY */
/*
* Some stuff just for C++
*/
#ifdef __cplusplus
}
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
#define _SIZE_T
#if (_MIPS_SZLONG == 32)
typedef unsigned int size_t;
#endif
#if (_MIPS_SZLONG == 64)
typedef unsigned long size_t;
#endif
#endif /* !_SIZE_T */
extern void* operator new(size_t size, TVHeap *hp);
#endif /* __cplusplus */
#endif /* __rkfsn_h_ */