File: io.tex

package info (click to toggle)
oskit 0.97.20000202-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 58,008 kB
  • ctags: 172,612
  • sloc: ansic: 832,827; asm: 7,640; sh: 3,920; yacc: 3,664; perl: 1,457; lex: 427; makefile: 337; csh: 141; awk: 78
file content (1269 lines) | stat: -rw-r--r-- 43,167 bytes parent folder | download
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
%
% Copyright (c) 1997-1999 University of Utah and the Flux Group.
% All rights reserved.
% 
% The University of Utah grants you the right to copy and reproduce this
% document or portions thereof for academic, research, evaluation, and
% personal use only, provided that (1) the title page appears prominently,
% and (2) these copyright and permission notices are retained in all copies.
% To arrange for alternate terms, contact the University of Utah at
% csl-dist@cs.utah.edu or +1-801-585-3271.
%
\label{oskit-io}

This chapter defines the I/O-related COM interfaces
which are defined by header files in the \texttt{oskit/io} directory.
Most of these interfaces are fairly generic
and can be used in a wide variety of situations.
Some of these interfaces, such as the \texttt{bufio} interface,
are extensions to other more primitive interfaces,
and allow objects to export the same functionality in different forms,
permitting clients to select the service that most directly meets their needs
thereby reducing interface crossing overhead
and increasing overall performance.


\apiintf{oskit_absio}{Absolute I/O Interface}
\label{oskit-absio}

	The {\tt oskit_absio} interface supports reading from and writing to
objects at specified absolute offsets, with no concept of a seek
pointer.  The {\tt oskit_absio} interface is identical to the
{\tt oskit_blkio} COM interface, except that the block size is always one,
since absolute IO is byte-oriented.
In fact, an object that supports byte-granularity reads and writes
can easily export both {\tt oskit_blkio} and {\tt oskit_absio}
using exactly the same function pointer table,
simply by implementing an {\tt oskit_blkio} interface
that always returns one from \texttt{getblocksize},
and then returning a pointer to that interface
on queries for either {\tt oskit_blkio} or {\tt oskit_absio}.

	The {\tt oskit_absio} COM interface inherits from {\tt IUnknown},
and has the following additional methods:	
\begin{csymlist}
\item[read]
	Read from this object, starting at the specified offset.
\item[write]
	Write to this object, starting at the specified offset.
\item[getsize]
	Get the current size of this object.
\item[setsize]
	Set the current size of this object.
\end{csymlist}

\api{read}{Read from this object, starting at specified offset}
\begin{apisyn}
	\cinclude{oskit/io/absio.h}

	\funcproto OSKIT_COMDECL
	oskit_absio_read(oskit_absio_t *f, 
		         void *buf,
	                 oskit_off_t offset,
			 oskit_size_t amount,
			 \outparam oskit_size_t *out_actual);
\end{apisyn}
\begin{apidesc}
	This method reads no more than {\tt amount} bytes into
	{\tt buf} from this object, starting at {\tt offset}.
	{\tt out_actual} is set to the actual number of bytes read.
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object from which to read.
	\item[buf]
		The buffer into which the data is to be copied.	
	\item[offset]
		The offset in this object at which to start reading.
	\item[amount]
		The maximum number of bytes to read.	
	\item[out_actual]
		The actual number of bytes read.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\api{write}{Write to this object, starting at specified offset}
\begin{apisyn}
	\cinclude{oskit/io/absio.h}

	\funcproto OSKIT_COMDECL
	oskit_absio_write(oskit_absio_t *f, 
		         const~void *buf,
	                 oskit_off_t offset,
			 oskit_size_t amount,
			 \outparam oskit_size_t *out_actual);
\end{apisyn}
\begin{apidesc}
	This method writes no more than {\tt amount} bytes from
	{\tt buf} into this object, starting at {\tt offset}.
	{\tt out_actual} is set to the actual number of bytes written.
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object to which to write.
	\item[buf]
		The buffer from which the data is to be copied.	
	\item[offset]
		The offset in this object at which to start writing.
	\item[amount]
		The maximum number of bytes to write.	
	\item[out_actual]
		The actual number of bytes written.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\api{getsize}{Get the size of this object}
\begin{apisyn}
	\cinclude{oskit/io/absio.h}

	\funcproto OSKIT_COMDECL
	oskit_absio_getsize(oskit_absio_t *f, 
			   \outparam oskit_off_t *out_size);
\end{apisyn}
\begin{apidesc}
	This method returns the current size of this object
	in bytes. 
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object whose size is desired.
	\item[out_size]
		The current size in bytes of this object.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{setsize}{Set the size of this object}
\begin{apisyn}
	\cinclude{oskit/io/absio.h}

	\funcproto OSKIT_COMDECL
	oskit_absio_setsize(oskit_absio_t *f, 
			   oskit_off_t new_size);
\end{apisyn}
\begin{apidesc}
	This method sets the size of this object to
	{\tt new_size} bytes.  If {\tt new_size}
	is larger than the former size of this object,
	then the contents of the object between its
	former end and its new end are undefined.

	Note that some absolute I/O objects may be fixed-size,
	such as objects representing preallocated memory buffers;
	in such cases,
	this method will always return \texttt{OSKIT_E_NOTIMPL}.
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object whose size is to be changed.
	\item[new_size]
		The new size in bytes for this object.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\apiintf{oskit_asyncio}{Asynchronous I/O Interface}
\label{oskit-asyncio}

The {\tt oskit_asyncio} interface provides interfaces in support
of basic asynchronous I/O, based on registered callback objects
(see Section~\ref{oskit-listener}).
This can be used, for example, to implement Unix {\tt SIGIO} or {\tt select}
or {\tt POSIX.1b aio}.

This interface supports a notion of three kinds of interesting events:
readability, writeability, and ``other'' exceptional conditions.
These are defined via the flags:
\ttindex{OSKIT_ASYNCIO_READABLE}\texttt{OSKIT_ASYNCIO_READABLE},
\ttindex{OSKIT_ASYNCIO_WRITEABLE}\texttt{OSKIT_ASYNCIO_WRITEABLE},
and \ttindex{OSKIT_ASYNCIO_EXCEPTION}\texttt{OSKIT_ASYNCIO_EXCEPTION}
which are passed and returned in a mask in the various methods. 

The {\tt oskit_asyncio} COM interface inherits from {\tt IUnknown},
and has the following additional methods:	
\begin{icsymlist}
\item[poll]
	Poll for currently pending asynchronous I/O conditions.
\item[add_listener]
	Add a callback object for async I/O events.
\item[remove_listener]
	Remove a previously registered callback object.
\item[readable]
	Returns the number of bytes that can be read. 
\end{icsymlist}

\api{poll}{Poll for pending asynchronous I/O conditions on this object}
\begin{apisyn}
	\cinclude{oskit/io/asyncio.h}

	\funcproto OSKIT_COMDECL
	oskit_asyncio_poll(oskit_asyncio_t *io);
\end{apisyn}
\begin{apidesc}
	Poll for currently pending asynchronous I/O conditions,
	returning a mask indicating which conditions are currently present.
\end{apidesc}
\begin{apiparm}
	\item[io]
		The async I/O object.
\end{apiparm}
\begin{apiret}
	If successful, returns a mask of the \texttt{OSKIT_ASYNCIO} flags above.
	Otherwise, returns an error code specified in
	{\tt <oskit/error.h>}.
\end{apiret}

\api{add_listener}{Associate a callback with this object}
\begin{apisyn}
	\cinclude{oskit/io/asyncio.h}

	\funcproto OSKIT_COMDECL
	oskit_asyncio_add_listener(oskit_asyncio_t *io, oskit_listener_t *l,
				   oskit_s32_t mask);
\end{apisyn}
\begin{apidesc}
	Add a callback listener object to handle asynchronous I/O events.
	When an event of interest occurs on this I/O object
	(i.e., when one of the one to three I/O conditions becomes true),
	{\em all} registered listeners will be called.

	The \texttt{mask} parameter is an OR'ed combination of the
	\texttt{OSKIT_ASYNCIO} flags above.
	It specifies which events the listener is interested in.
	Note that spurious notifications are possible, the listener
	must use \texttt{oskit_asyncio_poll} to determine the actual state
	of affairs.

	Also, if successful, this method returns a mask
	describing which of the \texttt{OSKIT_ASYNCIO} conditions are
	already true,
	which the caller must check in order to avoid missing events
	that occur just before the listener is registered.
\end{apidesc}
\begin{apiparm}
	\item[io]
		The async I/O object.
	\item[l]
		The \texttt{oskit_listener} object to call.
	\item[mask]
		A mask of flags indicating which events are of interest.
\end{apiparm}
\begin{apiret}
	If successful, returns a mask of the \texttt{OSKIT_ASYNCIO}
	currently pending.
	Otherwise, returns an error code specified in
	{\tt <oskit/error.h>}.
\end{apiret}

\api{remove_listener}{Disassociate a callback from this object}
\begin{apisyn}
	\cinclude{oskit/io/asyncio.h}

	\funcproto OSKIT_COMDECL
	oskit_asyncio_remove_listener(oskit_asyncio_t *io, oskit_listener_t *l);
\end{apisyn}
\begin{apidesc}
	Remove a previously registered listener callback object.
	Returns an error if the specified callback has not been registered.
\end{apidesc}
\begin{apiparm}
	\item[io]
		The async I/O object.
	\item[l]
		The \texttt{oskit_listener} object to call.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{readable}{Return the number of bytes available for reading from this object}
\begin{apisyn}
	\cinclude{oskit/io/asyncio.h}

	\funcproto OSKIT_COMDECL
	oskit_asyncio_readable(oskit_asyncio_t *io);
\end{apisyn}
\begin{apidesc}
	Returns the number of bytes that can be read from the I/O object.
\end{apidesc}
\begin{apiparm}
	\item[io]
		The async I/O object.
\end{apiparm}
\begin{apiret}
	The number of bytes available for reading.
\end{apiret}


\apiintf{oskit_blkio}{Block I/O Interface}
\label{oskit-blkio}

The {\tt oskit_blkio} interface supports reading and writing of raw data
in units of fixed-sized blocks which are some power of two.
This interface is identical to the {\tt oskit_absio} interface
except for the addition of a \texttt{getblocksize} method;
in fact, an object that supports byte-granularity reads and writes
can easily export both {\tt oskit_blkio} and {\tt oskit_absio}
using exactly the same function pointer table,
simply by implementing an {\tt oskit_blkio} interface
that always returns one from \texttt{getblocksize},
and then returning a pointer to that interface
on queries for either {\tt oskit_blkio} or {\tt oskit_absio}.

The {\tt oskit_blkio} interface inherits from {\tt IUnknown},
and has the following additional methods:	
\begin{icsymlist}
\item[getblocksize]
	Return the minimum block size of this block I/O object.
\item[read]
	Read from this object, starting at the specified offset.
\item[write]
	Write to this object, starting at the specified offset.
\item[getsize]
	Get the current size of this object.
\item[setsize]
	Set the current size of this object.
\end{icsymlist}

\api{getblocksize}{Return the minimum block size of this block I/O object}
\begin{apisyn}
	\cinclude{oskit/io/blkio.h}

	\funcproto OSKIT_COMDECL_U
	oskit_blkio_getblocksize(oskit_blkio_t *f);
\end{apisyn}
\begin{apidesc}
	This method simply returns the block size of the object,
	which must be a power of two.
	Calls by the client to read from or write to the object
	must only use offsets and sizes
	that are evenly divisible by this block size.
\end{apidesc}
\begin{apiparm}
	\item[f]
		The block I/O object.
\end{apiparm}
\begin{apiret}
	Returns the block size of the object.
\end{apiret}


\api{read}{Read from this object, starting at specified offset}
\begin{apisyn}
	\cinclude{oskit/io/blkio.h}

	\funcproto OSKIT_COMDECL
	oskit_blkio_read(oskit_blkio_t *f, 
		         void *buf,
	                 oskit_off_t offset,
			 oskit_size_t amount,
			 \outparam oskit_size_t *out_actual);
\end{apisyn}
\begin{apidesc}
	This method reads no more than {\tt amount} bytes into
	{\tt buf} from this object, starting at {\tt offset}.
	{\tt out_actual} is set to the actual number of bytes read.
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object from which to read.
	\item[buf]
		The buffer into which the data is to be copied.	
	\item[offset]
		The offset in this object at which to start reading.
		Must be a multiple of the object's block size.
	\item[amount]
		The maximum number of bytes to read.	
		Must be a multiple of the object's block size.
	\item[out_actual]
		The actual number of bytes read.
		Must be a multiple of the object's block size.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\api{write}{Write to this object, starting at specified offset}
\begin{apisyn}
	\cinclude{oskit/io/blkio.h}

	\funcproto OSKIT_COMDECL
	oskit_blkio_write(oskit_blkio_t *f, 
		         const~void *buf,
	                 oskit_off_t offset,
			 oskit_size_t amount,
			 \outparam oskit_size_t *out_actual);
\end{apisyn}
\begin{apidesc}
	This method writes no more than {\tt amount} bytes from
	{\tt buf} into this object, starting at {\tt offset}.
	{\tt out_actual} is set to the actual number of bytes written.
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object to which to write.
	\item[buf]
		The buffer from which the data is to be copied.	
	\item[offset]
		The offset in this object at which to start writing.
		Must be a multiple of the object's block size.
	\item[amount]
		The maximum number of bytes to write.	
		Must be a multiple of the object's block size.
	\item[out_actual]
		The actual number of bytes written.
		Must be a multiple of the object's block size.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\api{getsize}{Get the size of this object}
\begin{apisyn}
	\cinclude{oskit/io/blkio.h}

	\funcproto OSKIT_COMDECL
	oskit_blkio_getsize(oskit_blkio_t *f, 
			   \outparam oskit_off_t *out_size);
\end{apisyn}
\begin{apidesc}
	This method returns the current size of this object
	in bytes. 
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object whose size is desired.
	\item[out_size]
		The current size in bytes of this object.
		Must be a multiple of the object's block size.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{setsize}{Set the size of this object}
\begin{apisyn}
	\cinclude{oskit/io/blkio.h}

	\funcproto OSKIT_COMDECL
	oskit_blkio_setsize(oskit_blkio_t *f, 
			   oskit_off_t new_size);
\end{apisyn}
\begin{apidesc}
	This method sets the size of this object to
	{\tt new_size} bytes.  If {\tt new_size}
	is larger than the former size of this object,
	then the contents of the object between its
	former end and its new end are undefined.

	Note that some block I/O objects may be fixed-size,
	such as objects representing physical disks or partitions;
	in such cases,
	this method will always return \texttt{OSKIT_E_NOTIMPL}.
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object whose size is to be changed.
	\item[new_size]
		The new size in bytes for this object.
		Must be a multiple of the object's block size.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\apiintf{oskit_bufio}{Buffer-based I/O interface}
\label{oskit-bufio}

The \texttt{oskit_bufio} interface extends the \texttt{oskit_absio} interface,
providing additional alternative methods of accessing the object's data.
In particular,
for objects whose data is stored in an in-memory buffer of some kind,
this interface allows clients to obtain direct access to the buffer itself
so that they can read and write data using
% the former is a bizzare way to describe it, I prefer the latter --mike
%ordinary C pointer arithmetic,
loads and stores,
rather than having to copy data into and out of the buffer
using the \texttt{read} and \texttt{write} methods.
In addition, this interface provides similar methods
to allow clients to ``wire'' the buffer's contents to physical memory,
enabling DMA-based hardware devices to access the buffer directly.

However, note that only the read/write methods,
inherited from \texttt{oskit_absio}, are mandatory;
the others may consistently fail with \texttt{OSKIT_E_NOTIMPL}
if they cannot be implemented efficiently in a particular situation.
In that case, the caller must use
the basic \texttt{read} and \texttt{write} methods instead to copy the data.
In other words,
\texttt{oskit_bufio} object implementations are not \emph{required}
to implement direct buffer access, either software- or DMA-based;
the purpose of this interface is merely to allow them
to provide this optional functionality easily and consistently.
In general,
the \texttt{map} and \texttt{wire} methods should only be implemented
if they can be done more efficiently than simply copying the data.
Further, even if a buffer I/O implementation
does implement \texttt{map} and/or \texttt{wire}
it may allow only one mapping or wiring to be in effect at once,
failing if the client attempts to map or wire the buffer a second time
before the first mapping is undone.
Similarly, on some buffer I/O implementations,
these operations may only work on certain areas of the buffer
or only when the request has certain size or alignment properties:
for example, a buffer object that stores data in discontiguous segments,
such as BSD's \texttt{mbuf} system,
may only allow a buffer to be mapped
if the requested region happens to fall entirely within one segment.
Thus, the client of a \texttt{bufio} object
should call the \texttt{map} or \texttt{wire} methods
whenever it can take advantage of direct buffer access,
but must always be prepared to fall back to the basic copying methods.

A particular buffer object may be semantically read-only or write-only;
it is assumed that parties passing \texttt{bufio} objects around
will agree upon this as part of their protocols.
For a read-only buffer, the \texttt{write} method may or may not fail,
and a mapping established using the \texttt{map} method
may or may not actually be a read-only memory mapping;
it is the client's responsibility not to attempt to write to the buffer.
Similarly, for a write-only buffer,
the \texttt{read} method may or may not fail;
it is the client's responsibility not to attempt to read from the buffer.

The \texttt{oskit_bufio} interface
extends the \texttt{oskit_absio} interface
with the following additional methods:
\begin{icsymlist}
\item[map]	Map some or all of this buffer into locally accessible memory.
\item[unmap]	Release a previously mapped region of this buffer.
\item[wire]	Wire a region of this buffer into contiguous physical memory.
\item[unwire]	Unwire a previously wired region of this buffer.
\item[copy]	Create a copy of the specified portion of this buffer.
\end{icsymlist}

\api{map}{Map some or all of this buffer into locally accessible memory}
\begin{apisyn}
	\cinclude{oskit/io/bufio.h}

	\funcproto OSKIT_COMDECL
	map(oskit_bufio_t *io, \outparam void **addr,
	    oskit_off_t offset, oskit_size_t amount);
\end{apisyn}
\begin{apidesc}
	This method attempts to map some or all of this buffer
	into memory directly accessible to the client,
	so that the client can access it using
	loads and stores.
	%simple pointer arithmetic.
	The operation may or may not succeed,
	depending on the parameters and the implementation of the object;
	if it fails, the client must be prepared
	to fall back to the basic \texttt{read} and \texttt{write} methods.
	If the mapping operation succeeds,
	the pointer returned is not guaranteed to have any particular alignment.

	If a call to the \texttt{map} method
	requests only a subset of the buffer to be mapped,
	the object may actually map more than the requested amount;
	however, since no information is passed back
	indicating how much of the buffer was actually mapped,
	the client must only attempt to access the region it requested.

	Note that this method does not necessarily twiddle with virtual memory,
	as its name may seem to imply;
	in fact in most cases in which it is implemented at all,
	it just returns a pointer to a buffer
	if the data is already in locally-accessible memory.
\end{apidesc}
\begin{apiparm}
	\item[io]
		The object whose contents are to be mapped.
	\item[addr]
		On success,
		the method returns in this parameter
		the address at which the client
		can directly access the requested buffer region.
	\item[offset]
		The offset into the buffer of the region to be mapped.
	\item[size]
		The size of the region to be mapped.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{unmap}{Release a previously mapped region of this buffer}
\begin{apisyn}
	\cinclude{oskit/io/bufio.h}

	\funcproto OSKIT_COMDECL
	unmap(oskit_bufio_t *io, void *addr,
	      oskit_off_t offset, oskit_size_t amount);
\end{apisyn}
\begin{apidesc}
	After a successful call to the \texttt{map} method,
	the client should call this method
	after it is finished accessing the buffer directly,
	so that the buffer object can clean up
	and free any resources that might be associated with the mapping.

	The \emph{addr} parameter passed to this method
	must be exactly the value returned by the \texttt{map} request,
	and the \emph{offset} and \emph{amount} parameters
	must be exactly the same as the values previously passed
	in the corresponding \texttt{map} call.
	In other words,
	clients must only attempt to unmap whole regions;
	they must not attempt to unmap only part of a region,
	or to unmap two previously mapped regions in one call,
	even if the two regions appear to be contiguous in memory.
\end{apidesc}
\begin{apiparm}
	\item[io]
		The object whose contents are to be mapped.
	\item[addr]
		The address of the mapped region,
		as returned from the corresponding \texttt{map} call.
	\item[offset]
		The offset into the buffer of the mapped region,
		as passed to the corresponding \texttt{map} call.
	\item[size]
		The size of the mapped region,
		as passed to the corresponding \texttt{map} call.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{wire}{Wire a region of this buffer into contiguous physical memory}
\begin{apisyn}
	\cinclude{oskit/io/bufio.h}

	\funcproto OSKIT_COMDECL
	wire(oskit_bufio_t *io, \outparam oskit_addr_t *phys_addr,
	     oskit_off_t offset, oskit_size_t amount);
\end{apisyn}
\begin{apidesc}
	This method attempts to wire down some or all of this buffer
	into memory directly accessible by DMA hardware.
	The operation may or may not succeed,
	depending on the parameters and the implementation of the object;
	if it fails, the client must be prepared
	to fall back to the basic \texttt{read} and \texttt{write} methods.

	If the wiring operation succeeds,
	the physical address of the buffer
	is guaranteed not to change or otherwise become invalid
	until the region is unwired or the \texttt{bufio} object is released.
	The wired buffer is not guaranteed
	to have any particular alignment or location properties:
	for example, on a PC,
	if the device that is going to be accessing the buffer
	requires memory below 16MB,
	then it must be prepared to use appropriate bounce buffers
	if the wired buffer turns out to be above 16MB.

	If a call to the \texttt{wire} method
	requests only a subset of the buffer to be mapped,
	the object may actually wire more than the requested amount;
	however, since no information is passed back
	indicating how much of the buffer was actually wired,
	the client must only attempt to use the region it requested.
\end{apidesc}
\begin{apiparm}
	\item[io]
		The object whose contents are to be wired.
	\item[addr]
		On success,
		the method returns in this parameter
		the physical address at which DMA hardware
		can directly access the requested buffer region.
	\item[offset]
		The offset into the buffer of the region to be wired.
	\item[size]
		The size of the region to be wired.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{unwire}{Unwire a previously wired region of this buffer}
\begin{apisyn}
	\cinclude{oskit/io/bufio.h}

	\funcproto OSKIT_COMDECL
	unwire(oskit_bufio_t *io, void *addr,
	       oskit_off_t offset, oskit_size_t amount);
\end{apisyn}
\begin{apidesc}
	After a successful call to the \texttt{wire} method,
	the client should call this method
	after the hardware is finished accessing the buffer directly,
	so that the buffer object can clean up
	and free any resources that might be associated with the wiring.

	The \emph{addr} parameter passed to this method
	must be exactly the value returned by the \texttt{wire} request,
	and the \emph{offset} and \emph{amount} parameters
	must be exactly the same as the values previously passed
	in the corresponding \texttt{wire} call.
	In other words,
	clients must only attempt to unwire whole regions;
	they must not attempt to unwire only part of a region,
	or to unwire two previously wired regions in one call,
	even if the two regions appear to be contiguous in physical memory.
\end{apidesc}
\begin{apiparm}
	\item[io]
		The object whose contents are to be wired.
	\item[addr]
		The address of the wired region,
		as returned from the corresponding \texttt{map} call.
	\item[offset]
		The offset into the buffer of the wired region,
		as passed to the corresponding \texttt{wire} call.
	\item[size]
		The size of the wired region,
		as passed to the corresponding \texttt{wire} call.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{copy}{Create a copy of the specified portion of this buffer}
\begin{apisyn}
	\cinclude{oskit/io/bufio.h}

	\funcproto OSKIT_COMDECL
	copy(oskit_bufio_t *io,
	       oskit_off_t offset, oskit_size_t amount,
	       \outparam oskit_bufio_t **out_io);
\end{apisyn}
\begin{apidesc}
	This method attempts to create
	a logical copy of a portion of this buffer object
	(possibly the whole buffer),
	returning a new \texttt{oskit_bufio} object representing the copy.
	As with the \texttt{map} and \texttt{wire} methods,
	this method should only be implemented by an object
	if it can be done more efficiently
	than a simple ``brute-force'' copy using \texttt{read}.
	For example, in virtual memory environments,
	the object may be able to use copy-on-write optimizations.
	Similarly, if the buffer's contents are stored
	in special memory not efficiently accessible to the processor,
	such as memory on a video or coprocessor board,
	this method could use on-board hardware to perform a much faster copy.
	% XXX shouldn't there also be a copyto method, as in stream?
\end{apidesc}
\begin{apiparm}
	\item[io]
		The object whose contents are to be copied.
	\item[offset]
		The offset into the buffer of the region to be copied.
	\item[size]
		The size of the region to be copied.
	\item[out_io]
		On success,
		this parameter holds the \texttt{bufio} object
		representing the newly created copy of the buffer's contents.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\apiintf{oskit_netio}{Network packet I/O interface}
\label{oskit-netio}

This interface builds on the above interfaces
to provide a clean and simple but powerful interface
for passing network packets between device drivers and protocol stacks,
and possibly between layers of a protocol stack as well.

The \texttt{oskit_netio} interface uses a symmetric sender-driven model
for asynchronous communication.
Each party involved
(e.g., the network device driver and the protocol stack)
must implement a \texttt{netio} object
and pass a reference to its own \texttt{netio} object to the other party.
For example,
in the \texttt{oskit_netdev} interface,
which represents a network device of some kind,
this exchange of \texttt{netio} objects occurs
when the protocol stack or other client opens the device.
The \texttt{oskit_netio} interface defines
only a single additional method
beyond the basic methods inherited from \texttt{oskit_iunknown};
this method, appropriately named \texttt{push},
is used to ``push'' a network packet to the ``other'' party.
For example, when a network device driver receives a packet from the hardware,
the driver calls the \texttt{push} method
on the \texttt{netio} object provided by the protocol stack;
conversely, when the protocol stack needs to send a packet,
it calls the \texttt{netio} object returned by the device driver
at the time the device was opened.
Thus, a \texttt{netio} object essentially represents a ``packet consumer.''

The following section describes the specifics of the \texttt{push} method.

\api{push}{Push a packet through to the packet consumer}
\begin{apisyn}
	\cinclude{oskit/io/netio.h}

	\funcproto OSKIT_COMDECL
	push(oskit_netio_t *io, oskit_bufio *buf, oskit_size_t size);
\end{apisyn}
\begin{apidesc}
	This method feeds a network packet
	to the packet consumer represented by the \texttt{netio} object;
	what the consumer does with the packet
	depends entirely on who the consumer is and how it is configured.
	The packet is contained in a \texttt{bufio} object
	which must be at least the size of the packet,
	but may be larger;
	the \emph{size} parameter on the \texttt{push} call
	indicates the actual size of the packet.

	If the consumer needs to hold on to the provided \texttt{bufio} object
	after returning from the call,
	it must call \texttt{addref} on the \texttt{bufio} object
	to obtain its own reference;
	then it must release this reference at some later time
	when it is done with the buffer.
	Otherwise, if the consumer doesn't obtain its own reference,
	the caller may recycle the buffer as soon as the call returns.

	The passed buffer object is logically read-only;
	the consumer must not attempt to write to it.
	The size parameter to this call is the actual size of the packet;
	the size of the buffer, as returned by the \texttt{getsize} method,
	may be larger than the size of the packet.
\end{apidesc}
\begin{apiparm}
	\item[io]
		The \texttt{oskit_netio} interface
		representing the packet consumer.
	\item[buf]
		The \texttt{oskit_bufio} interface
		to the buffer object containing the packet.
	\item[size]
		The actual size of the packet;
		must be less than or equal to
		the size of the buffer object.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\apiintf{oskit_posixio}{\posix{} I/O interface}
\label{oskit-posixio}

	The {\tt oskit_posixio} interface defines the minimal \posix{} I/O
interface that any \posix{} I/O object (file, device, pipe, socket, etc)
can be expected to support.  Only per-object methods are provided by
this interface.  Additional I/O operations are supported through
separate interfaces, such as the {\tt oskit_stream} interface and
{\tt oskit_absio} COM interface.

	The {\tt oskit_posixio} COM interface inherits from {\tt oskit_iunknown},
and has the following additional methods:	
\begin{icsymlist}
\item[stat]
	Get this object's attributes.
\item[setstat]
	Set this object's attributes.
\item[pathconf]
	Get this object's value for a configuration option variable. 
\end{icsymlist}

\api{stat}{Get attributes of this object}
\begin{apisyn}
	\cinclude{oskit/io/posixio.h}

	\funcproto OSKIT_COMDECL
	oskit_posixio_stat(oskit_posixio_t *f, 
			   \outparam oskit_stat_t *out_stats);
\end{apisyn}
\begin{apidesc}
	This method returns the attributes of this object.
	Depending on the type of object, only some of the attributes
	may be meaningful.  {\tt out_stats} is a pointer to a 
	{\tt oskit_stat_t} structure defined as follows: 
\com{Cannot use cstruct macro: TeX capacity exceeded, sorry [parameter stack size=60].}%com
{\par{\tt struct } {\large\bf oskit_stat} \{\\
\begin{tabular}{lllll}
~&{\tt oskit_dev_t}&{\tt	dev};&/* device on which inode resides &*/\\
~&{\tt oskit_ino_t}&{\tt ino};&/* inode's number &*/\\
~&{\tt oskit_mode_t}&{\tt mode};&/* file mode &*/\\
~&{\tt oskit_nlink_t}&{\tt nlink};&/* number of hard links to file &*/\\
~&{\tt oskit_uid_t}&{\tt uid};&/* user id of owner &*/\\
~&{\tt oskit_gid_t}&{\tt gid};&/* group id of owner &*/\\
~&{\tt oskit_dev_t}&{\tt rdev};&/* device number, for device files &*/\\
~&{\tt oskit_timespec_t}&{\tt atime};&/* time of last access &*/\\
~&{\tt oskit_timespec_t}&{\tt mtime};&/* time of last data modification &*/\\
~&{\tt oskit_timespec_t}&{\tt ctime};&/* time of last attribute change &*/\\
~&{\tt oskit_off_t}&{\tt size};&/* size in bytes &*/\\
~&{\tt oskit_u64_t}&{\tt blocks};&/* blocks allocated for file &*/ \\
~&{\tt oskit_u32_t}&{\tt blksize};&/* optimal block size in bytes &*/\\
\end{tabular} \\ \}; }
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object whose attributes are desired.
	\item[out_stats]
		The attributes of the specified object.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\api{setstat}{Set the attributes of this object}
\begin{apisyn}
	\cinclude{oskit/io/posixio.h}

	\funcproto OSKIT_COMDECL
	oskit_posixio_setstat(oskit_posixio_t *f, 
			      oskit_u32_t mask,
			      const~oskit_stat_t *stat);
\end{apisyn}
\begin{apidesc}
	This method sets the attributes specified in {\tt mask}
	to the values specified in {\tt stat}.  {\tt mask} may
	be any combination of the following:
\begin{icsymlist}
\item[OSKIT_STAT_MODE]
	Set the file mode, except for the file type bits, as in
	the Unix {\tt chmod} system call.  
\item[OSKIT_STAT_UID]
	Set the file user id, as in the Unix {\tt chown} system call.
\item[OSKIT_STAT_GID]  
	Set the file group id, as in the Unix {\tt chown} system call.
\item[OSKIT_STAT_SIZE]
	Set the file size, as in the Unix {\tt truncate} system call.
\item[OSKIT_STAT_ATIME] 
	Set the file's last access timestamp to a particular
	value, as in the Unix {\tt utimes} system call with 
	a non-{\tt NULL} parameter.
\item[OSKIT_STAT_MTIME]
	Set the file's last data modification timestamp to a particular
	value, as in the Unix {\tt utimes} system call 
	with a non-{\tt NULL} parameter. 
\item[OSKIT_STAT_UTIMES_NULL]
	Set the file's last access timestamp and data modification
	timestamp to the current time, as in
	the Unix {\tt utimes} system call with a {\tt NULL}
	parameter.  
\end{icsymlist}

	Typically, this method is not supported for symbolic links.
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object whose attributes are to be changed.
	\item[mask]
		The attributes to be changed. 
	\item[stat]
		The new attribute values.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\api{pathconf}{Get value of a configuration option variable}
\begin{apisyn}
	\cinclude{oskit/io/posixio.h}

	\funcproto OSKIT_COMDECL
	oskit_posixio_pathconf(oskit_posixio_t *f, 
			      oskit_s32_t option,
			      \outparam oskit_s32_t *out_val);
\end{apisyn}
\begin{apidesc}
	This method returns the value of the specified 
	configuration option variable for this object.
	The value of {\tt option} may be one of the following: 
\begin{icsymlist}
\item[OSKIT_PC_LINK_MAX]
	Get the maximum file link count.
\item[OSKIT_PC_MAX_CANON]
	Get the maximum size of the terminal input line.
\item[OSKIT_PC_MAX_INPUT]
	Get the maximum input queue size.
\item[OSKIT_PC_NAME_MAX]
	Get the maximum number of bytes in a filename.
\item[OSKIT_PC_PATH_MAX]
	Get the maximum number of bytes in a pathname.
\item[OSKIT_PC_PIPE_BUF]
	Get the maximum atomic write size to a pipe.
\item[OSKIT_PC_CHOWN_RESTRICTED]
	Determine whether use of chown is restricted.
\item[OSKIT_PC_NO_TRUNC]
	Determine whether too-long pathnames produce errors.
\item[OSKIT_PC_VDISABLE]
	Get value to disable special terminal characters.
\item[OSKIT_PC_ASYNC_IO]
	Determine whether asynchronous IO is supported.
\item[OSKIT_PC_PRIO_IO]
	Determine whether prioritized IO is supported.
\item[OSKIT_PC_SYNC_IO]
	Determine whether synchronized IO is supported.
\end{icsymlist}
\end{apidesc}
\begin{apiparm}
	\item[f]
		The object from which to obtain a configuration option value
	\item[option]
		The configuration option variable
	\item[out_val]
		The value of the configuration option value.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}


\apiintf{oskit_ttystream}{Interface to Unix TTY-like streams}
\label{oskit-ttystream}

This interface extends the standard COM \texttt{IStream} interface
with \posix/Unix TTY functionality,
such as methods to control serial port settings,
enable, disable, and control line editing,
flush the input and output queues, etc.

This interface is currently exported by character-oriented device drivers
incorporated into the \oskit{} from legacy systems such as BSD and Linux,
in which full Unix TTY functionality can be provided easily.
In the future,
these drivers are expected to export more minimal, lower-level interfaces
instead of or in addition to this interface;
however, in the short term,
this interface allows clients
to obtain full Unix terminal functionality quickly and easily.

The {\tt oskit_ttystream} interface inherits from {\tt oskit_stream},
and has the following additional methods:	
\begin{csymlist}
\item[getattr]
	Get the stream's current TTY attributes.
\item[setattr]
	Set the stream's TTY attributes.
\item[sendbreak]
	Send a break signal over the line.
\item[drain]
	Wait until all buffered output has been transmitted.
\item[flush]
	Discared buffered input and/or output data.
\item[flow]
	Suspend or resume data transmission or reception.
% XXX more, which aren't used at the moment
\end{csymlist}

In addition,
this header file defines a structure called \texttt{oskit_termios},
corresponding to the standard \posix{} \texttt{termios} structure,
and a set of related definitions
used to specify terminal-related settings.
See the \posix{} and Unix standards
for details on the exact contents and meaning of this structure.

\api{getattr}{Get the stream's current TTY attributes}
\begin{apisyn}
	\cinclude{oskit/io/ttystream.h}

	\funcproto OSKIT_COMDECL
	getattr(oskit_ttystream_t *tty, 
		\outparam struct~oskit_termios *attr);
\end{apisyn}
\begin{apidesc}
	This method retrieves the current line settings of this stream
	and returns them in the specified \texttt{oskit_termios} structure.
	This method corresponds to the \posix{} \texttt{tcgetattr} function;
	see the \posix{} standard for details.
\end{apidesc}
\begin{apiparm}
	\item[tty]
		The TTY stream object to query.
	\item[attr]
		The structure to be filled with the current line settings.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{setattr}{Set the stream's TTY attributes}
\begin{apisyn}
	\cinclude{oskit/io/ttystream.h}

	\funcproto OSKIT_COMDECL
	setattr(oskit_ttystream_t *tty, 
		const~struct~oskit_termios *attr);
\end{apisyn}
\begin{apidesc}
	This method sets the line settings of this stream
	based on the specified \texttt{oskit_termios} structure.
	This method corresponds to the \posix{} \texttt{tcsetattr} function;
	see the \posix{} standard for details.
\end{apidesc}
\begin{apiparm}
	\item[tty]
		The TTY stream object to modify.
	\item[attr]
		The structure containing the new line settings.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{sendbreak}{Send a break signal}
\begin{apisyn}
	\cinclude{oskit/io/ttystream.h}

	\funcproto OSKIT_COMDECL
	sendbreak(oskit_ttystream_t *tty, oskit_u32_t duration);
\end{apisyn}
\begin{apidesc}
	On streams controlling asynchronous serial communication,
	this method sends a break signal
	(a continuous stream of zero-valued bits)
	for a specific duration.
	This method corresponds to the \posix{} \texttt{tcsendbreak} function;
	see the \posix{} standard for details.
\end{apidesc}
\begin{apiparm}
	\item[tty]
		The TTY stream on which to send the break.
	\item[duration]
		% XXX define the meaning of the duration parameter, or axe it.
		The duration of the break signal to send.
		If this parameter is zero,
		then the duration will be
		between 0.25 and 0.5 seconds.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{drain}{Wait until all buffered output has been transmitted}
\begin{apisyn}
	\cinclude{oskit/io/ttystream.h}

	\funcproto OSKIT_COMDECL
	drain(oskit_ttystream_t *tty);
\end{apisyn}
\begin{apidesc}
	This method waits until any buffered output data
	that has been written to the stream
	is successfully transmitted.
	This method corresponds to the \posix{} \texttt{tcdrain} function;
	see the \posix{} standard for details.
\end{apidesc}
\begin{apiparm}
	\item[tty]
		The TTY stream object to drain.
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{flush}{Discared buffered input and/or output data}
\begin{apisyn}
	\cinclude{oskit/io/ttystream.h}

	\funcproto OSKIT_COMDECL
	flush(oskit_ttystream_t *tty, int queue_selector);
\end{apisyn}
\begin{apidesc}
	This method discards
	any buffered output data that has not yet been transmitted,
	and/or any buffered input data that has not yet been read,
	depending on the \emph{queue_selector} parameter.
	This method corresponds to the \posix{} \texttt{tcflush} function;
	see the \posix{} standard for details.
\end{apidesc}
\begin{apiparm}
	\item[tty]
		The TTY stream object to flush.
	\item[queue_selector]
		Must be one of the following:
		\begin{icsymlist}
		\item[OSKIT_TCIFLUSH]	Flush the input buffer.
		\item[OSKIT_TCOFLUSH]	Flush the output buffer.
		\item[OSKIT_TCIOFLUSH]	Flush the input and output buffers.
		\end{icsymlist}
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}

\api{flow}{Suspend or resume data transmission or reception}
\begin{apisyn}
	\cinclude{oskit/io/ttystream.h}

	\funcproto OSKIT_COMDECL
	flow(oskit_ttystream_t *tty, int action);
\end{apisyn}
\begin{apidesc}
	This method controls the transmission or reception of data
	on this TTY stream.
	This method corresponds to the \posix{} \texttt{tcflow} function;
	see the \posix{} standard for details.
\end{apidesc}
\begin{apiparm}
	\item[tty]
		The TTY stream object to control.
	\item[action]
		Must be one of the following:
		\begin{icsymlist}
		\item[OSKIT_TCOOFF]	Suspend output.
		\item[OSKIT_TCOON]	Restart output.
		\item[OSKIT_TCIOFF]	Transmit a STOP character.
		\item[OSKIT_TCION]	Transmit a START character.
		\end{icsymlist}
\end{apiparm}
\begin{apiret}
	Returns 0 on success, or an error code specified in
	{\tt <oskit/error.h>}, on error.
\end{apiret}