Skip to content

Commit 23fc5e3

Browse files
osss
1 parent d5a64c7 commit 23fc5e3

File tree

1 file changed

+56
-27
lines changed

1 file changed

+56
-27
lines changed

docs/source/os.rst

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ you can call from the 6502. The :doc:`os` does not use any 6502 system RAM
1212
and will not interfere with developing a native 6502 OS.
1313

1414
The :doc:`os` is loosely based on POSIX with an Application Binary
15-
Interface (ABI) similar to `cc65 <https://cc65.github.io>`_'s fastcall.
15+
Interface (ABI) similar to `cc65 <https://cc65.github.io>`__'s fastcall.
1616
It provides stdio.h and unistd.h services to both `cc65
17-
<https://cc65.github.io>`_ and `llvm-mos <https://llvm-mos.org/>`_
17+
<https://cc65.github.io>`__ and `llvm-mos <https://llvm-mos.org/>`_
1818
compilers. There are also calls to access RP6502 features and manage
1919
FAT32 filesystems. ExFAT is ready to go and will be enabled when the
2020
patents expire.
@@ -61,7 +61,7 @@ Application Binary Interface (ABI)
6161
The binary interface for calling the operating system is based on
6262
fastcall from the `cc65 internals
6363
<https://cc65.github.io/doc/cc65-intern.html>`_. The :doc:`os`
64-
fastcall does not use or require anything from cc65 and is easy for
64+
does not use or require anything from cc65 and is easy for
6565
assembly programmers to use. At its core, the OS ABI is four simple rules.
6666

6767
* Stack arguments are pushed left to right.
@@ -250,37 +250,42 @@ zxstack
250250
-------
251251
.. c:function:: void zxstack(void);
252252
253-
Abandon the xstack by resetting the xstack pointer. This is the only
254-
operation that doesn't require waiting for completion. You do not need
255-
to call this for failed operations. It can be useful if you want to
256-
quickly ignore part of a returned structure.
253+
Abandon the xstack by resetting the xstack pointer. This is the only
254+
operation that doesn't require waiting for completion. You do not need
255+
to call this for failed operations. It can be useful if you want to
256+
quickly ignore part of a returned structure.
257+
258+
:Op code: RIA_OP_ZXSTACK 0x00
259+
:C proto: rp6502.h
257260

258261
xreg
259262
----
260263

261264
.. c:function:: int xreg(char device, char channel, unsigned char address, ...);
262265
.. c:function:: int xregn(char device, char channel, unsigned char address, unsigned count, ...);
263266
264-
The only difference is that xregn() requires a count of the variadic
265-
arguments. Using xreg() avoids making a counting error and is
266-
slightly smaller in cc65.
267+
Using xreg() from C is preferred to avoid making a counting error.
268+
Count doesn't need to be sent in the ABI so both prototypes are correct.
267269

268-
Set extended registers on a PIX device. See the :doc:`ria` and
270+
The variadic argument is a list of ints to be stored in extended registers
271+
starting at address on the specified device and channel.
272+
See the :doc:`ria` and
269273
:doc:`vga` documentation for what each register does. Setting
270-
extended registers can fail, which you should use for feature
274+
extended registers can fail, which you can use for feature
271275
detection. EINVAL means the device responded with a negative
272276
acknowledgement. EIO means there was a timeout waiting for ack/nak.
273277

274-
This is how you add virtual hardware to extended RAM. The 64K of
275-
system RAM is mapped by address decode logic ICs. The 64K of extended
276-
RAM is mapped with this command. Mapping a real sound chip to system
277-
RAM requires schematics and wires. Mapping a virtual sound chip to
278-
extended RAM is a single xreg() command.
278+
This is how you add virtual hardware to extended RAM. Both the :doc:`ria` and
279+
:doc:`vga` have a selection of virtual devices you can install. You can also
280+
make your own hardware for the PIX bus and configure it with this call.
279281

280-
:param device: PIX device ID. 0-6
282+
:Op code: RIA_OP_XREG 0x01
283+
:C proto: rp6502.h
284+
:param device: PIX device ID. 0:RIA, 1:VGA, 2-6:unassigned
281285
:param channel: PIX channel. 0-15
282286
:param address: PIX address. 0-255
283287
:param ...: 16 bit integers to set starting at address.
288+
:a regs: return
284289
:errno: EINVAL, EIO
285290

286291

@@ -292,6 +297,8 @@ phi2
292297
Retrieves the PHI2 setting from the RIA. Applications can use this
293298
for adjusting to or rejecting different clock speeds.
294299
300+
:Op code: RIA_OP_PHI2 0x02
301+
:C proto: rp6502.h
295302
:returns: The 6502 clock speed in kHz. Typically 800 <= x <= 8000.
296303
:errno: will not fail
297304
@@ -308,8 +315,9 @@ codepage
308315
page is unavailable, a different code page will be selected and
309316
returned. For example: ``if (850!=codepage(850)) puts("error");``
310317
318+
:Op code: RIA_OP_CODEPAGE 0x03
319+
:C proto: rp6502.h
311320
:param cp: code page or 0 for system setting.
312-
313321
:returns: The code page. One of: 437, 720, 737, 771, 775, 850, 852,
314322
855, 857, 860, 861, 862, 863, 864, 865, 866, 869, 932, 936, 949,
315323
950.
@@ -326,6 +334,8 @@ lrand
326334
cc65 library can be seeded with this by calling its non-standard
327335
_randomize() function.
328336
337+
:Op code: RIA_OP_LRAND 0x04
338+
:C proto: rp6502.h
329339
:returns: Chaos. 0x0 <= x <= 0x7FFFFFFF
330340
:errno: will not fail
331341
@@ -335,12 +345,15 @@ stdin_opt
335345
336346
.. c:function:: int stdin_opt(unsigned long ctrl_bits, unsigned char str_length)
337347
338-
*** Experimental *** (likely to be replaced with stty-like something)
339-
340348
Additional options for the STDIN line editor. Set the str_length to
341349
your buffer size - 1 to make gets() safe. This can also guarantee no
342350
split lines when using fgets() on STDIN.
343351
352+
*** Experimental *** Likely to be replaced with stty-like something. Drop your
353+
thoughts on the forums if you have specific needs.
354+
355+
:Op code: RIA_OP_STDIN_OPT 0x05
356+
:C proto: rp6502.h
344357
:param ctrl_bits: Bitmap of ASCII 0-31 defines which CTRL characters
345358
can abort an input. When CTRL key is pressed, any typed input
346359
remains on the screen but the applicaion receives a line containing
@@ -360,6 +373,8 @@ clock
360373
Obtain the value of a monotonic clock that updates 100 times per
361374
second. Wraps approximately every 497 days.
362375
376+
:Op code: RIA_OP_CLOCK 0x0F
377+
:C proto: time.h
363378
:returns: 1/100 second monotonic clock
364379
:errno: will not fail
365380
@@ -376,8 +391,10 @@ clock_getres
376391
int32_t tv_nsec; /* nanoseconds */
377392
};
378393
379-
Copies the clock resolution to `res`.
394+
Obtains the clock resolution for `res`.
380395
396+
:Op code: RIA_OP_CLOCK_GETRES 0x10
397+
:C proto: time.h
381398
:param clock_id: 0 for CLOCK_REALTIME.
382399
:returns: 0 on success. -1 on error.
383400
:a regs: return, clock_id
@@ -389,8 +406,10 @@ clock_gettime
389406
390407
.. c:function:: int clock_gettime(clockid_t clock_id, struct timespec *tp)
391408
392-
Copies the current time to `tp`.
409+
Obtains the current time for `tp`.
393410
411+
:Op code: RIA_OP_CLOCK_GETTIME 0x11
412+
:C proto: time.h
394413
:param clock_id: 0 for CLOCK_REALTIME.
395414
:returns: 0 on success. -1 on error.
396415
:a regs: return, clock_id
@@ -402,8 +421,10 @@ clock_settime
402421
403422
.. c:function:: int clock_settime(clockid_t clock_id, const struct timespec *tp)
404423
405-
Sets the current time to `tp`.
424+
Sets the current time as `tp`.
406425
426+
:Op code: RIA_OP_CLOCK_SETTIME 0x12
427+
:C proto: time.h
407428
:param clock_id: 0 for CLOCK_REALTIME.
408429
:returns: 0 on success. -1 on error.
409430
:a regs: return, clock_id
@@ -429,6 +450,11 @@ clock_gettimezone
429450
`help set tz` on the monitor to learn about configuring your time
430451
zone.
431452
453+
*** Experimental *** time zones in cc65 are incomplete probably because
454+
no other 6502 OS supports them.
455+
456+
:Op code: RIA_OP_CLOCK_GETTIMEZONE 0x13
457+
:C proto: None, Experimental
432458
:param time: time_t compatible integer.
433459
:param clock_id: 0 for CLOCK_REALTIME.
434460
:returns: 0 on success. -1 on error.
@@ -441,8 +467,11 @@ open
441467
442468
.. c:function:: int open(const char *path, int oflag)
443469
444-
Create a connection between a file and a file descriptor.
470+
Create a connection between a file and a file descriptor. Up to 8
471+
files may be open at once.
445472
473+
:Op code: RIA_OP_OPEN 0x14
474+
:C proto: fcntl.h
446475
:param path: Pathname to a file.
447476
:param oflag: Bitfield of options.
448477
:returns: File descriptor. -1 on error.
@@ -475,8 +504,8 @@ close
475504
476505
.. c:function:: int close(int fildes)
477506
478-
Release the file descriptor. File descriptor will rejoin the pool
479-
available for use by open().
507+
Finish pending writes and release the file descriptor. File descriptor
508+
will rejoin the pool available for use by open().
480509
481510
:param fildes: File descriptor from open().
482511
:returns: 0 on success. -1 on error.

0 commit comments

Comments
 (0)