466
|
1 <refentry id="os9">
|
|
2 <refnamediv>
|
468
|
3 <refname>_os9</refname>
|
|
4 <refpurpose>system call interface from C programs</refpurpose>
|
466
|
5 </refnamediv>
|
|
6
|
|
7 <refsynopsisdiv>
|
|
8 <funcsynopsis>
|
468
|
9 <funcsynopsisinfo>
|
|
10 #include <os9.h>
|
|
11 </funcsynopsisinfo>
|
466
|
12 <funcprototype>
|
468
|
13 <funcdef><function>_os9</function></funcdef>
|
572
|
14 <paramdef>char <parameter>code</parameter></paramdef>
|
|
15 <paramdef>struct registers *<parameter>reg</parameter></paramdef>
|
466
|
16 </funcprototype>
|
|
17 </funcsynopsis>
|
|
18
|
|
19 </refsynopsisdiv>
|
|
20
|
|
21 <refsect1><title>Description</title>
|
|
22 <para>
|
602
|
23 _os9 enables a programmer to access virtually any OS-9 system
|
|
24 call directly from a C program without having to resort to
|
|
25 assembly language routines.
|
|
26 </para>
|
|
27 <para>
|
|
28 <varname>Code</varname> is one of the codes that are defines in os9.h. os9.h
|
|
29 contains codes for the F$ and I$ function/service requests, and
|
|
30 it also contains getstt, setstt, and error codes.
|
|
31 </para>
|
|
32 <para>
|
|
33 The input registers(reg) for the system calls are accessed by
|
|
34 the following structure that is defined in os9.h:
|
|
35 <programlisting>
|
|
36 struct registers {
|
|
37 char rg_cc,rg_a,rg_b,rg_dp;
|
|
38 unsigned rg_x,rg_y,rg_u;
|
|
39 };
|
|
40 </programlisting>
|
|
41 An example program that uses _os9 is presented on the following page.
|
466
|
42 </para>
|
|
43 </refsect1>
|
534
|
44
|
|
45 <refsect1><title>Diagnostics</title>
|
|
46 <para>
|
|
47 -1 is returned is the OS-9 call failed. 0 is returned on success.
|
|
48 </para>
|
|
49 </refsect1>
|
|
50
|
|
51 <refsect1><title>Program Example</title>
|
|
52 <programlisting>
|
|
53 #include <os9.h>
|
|
54 #include <modes.h>
|
|
55
|
|
56 /* this program does an I$GETSTT call to get file size */
|
|
57 main(argc,argv)
|
|
58 int argc;
|
|
59 char **argv;
|
|
60 {
|
|
61 struct registers reg;
|
|
62 int path;
|
|
63
|
|
64 /* tell linker we need longs */
|
|
65 pflinit();
|
|
66
|
|
67 /* low level open(file name is first command line param */
|
|
68 path=open(*++argv,S_IREAD);
|
|
69
|
|
70 /* set up regs for call to OS-9 */
|
|
71 reg.rg_a=path;
|
|
72 reg.rg_b=SS_SIZE;
|
|
73
|
|
74 if(_os9(I_GETSTT,&reg) == 0)
|
|
75 printf("filesize = %lx\n", /* success */
|
|
76 (long) (reg.rg_x << 16)+reg.rg_u);
|
|
77 else printf("OS9 error #%d\n",reg.rg_b & 0xff); /*failed*/
|
|
78
|
|
79 dumpregs(&reg); /* take a look at the registers */
|
|
80 }
|
|
81
|
|
82 dumpregs(r)
|
|
83 register struct registers *r;
|
|
84 {
|
|
85 printf("cc=%02x\n",r->rg_cc & 0xff);
|
|
86 printf(" a=%02x\n",r->rg_a & 0xff);
|
|
87 printf(" b=%02x\n",r->rg_b & 0xff);
|
|
88 printf("dp=%02x\n",r->rg_dp & 0xff);
|
|
89 printf(" x=%02x\n",r->rg_x);
|
|
90 printf(" y=%02x\n",r->rg_u);
|
|
91 printf(" u=%02x\n",r->rg_y);
|
|
92 }
|
|
93 </programlisting>
|
|
94 </refsect1>
|
466
|
95 </refentry>
|