Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.7KB

  1. # Protocols
  2. Some subsystems (and in the case of KEY and EMIT, the core) re-
  3. quire drivers to implement certain words in a certain way. For
  4. example, the core requires drivers to implement (key?) and
  5. (emit) or else it won't know how to provide a console.
  6. These protocols are described here.
  7. # TTY protocol
  8. (key?) -- c? f Returns whether a key has been pressed and,
  9. if it has, returns which key. When f is
  10. false, c is *not* placed in the stack.
  11. (emit) c -- Spit a character on the console.
  12. # PS/2 protocol
  13. This protocol enables communication with a device that spits
  14. PS/2 keycodes.
  15. (ps2kc) -- kc Returns the next typed PS/2 keycode from the
  16. console. 0 if nothing was typed.
  17. # SPI Relay protocol
  18. This protocol enables communication with a SPI relay. This
  19. protocol is designed to support devices with multiple endpoints.
  20. To that end, (spie) takes a device ID argument, with a meaning
  21. that is up to the device itself. To disable all devices, supply
  22. 0 to (spie).
  23. We expect relay devices to support only one enabled device at
  24. once. Enabling a specific device is expected to disable the
  25. previously enabled one.
  26. (spie) n -- Enable SPI device
  27. (spix) n -- n Perform SPI exchange (push a number, get a
  28. number back)
  29. # Grid protocol
  30. A grid is a device that shows as a grid of ASCII characters and
  31. allows random access to it.
  32. COLS -- n Number of columns in the device
  33. LINES -- n Number of lines in the device
  34. CELL! c pos -- Set character at pos
  35. Optional:
  36. NEWLN ln -- "Enter" line ln
  37. CURSOR! new old -- Move cursor from old pos to new pos
  38. "pos" is a simple number (y * cols) + x. For example, if we
  39. have 40 columns per line, the position (x, y) (12, 10) is 412.
  40. CELL! is not expected to be called with an out-of-range char-
  41. acter. For example, glyphs are often mapped starting at 0x20
  42. (space). On most systems, CELL! should not be called with c <
  43. 0x20.If it is, CELL! should do nothing.
  44. NEWLN is called when we "enter" a new line, that is, when we
  45. overflow from previous line or when 0x0d ( ASCII CR ) is emit-
  46. ted.
  47. When this is called, the line being entered should be cleared
  48. of its contents. On some systems, some kinf of screen offset
  49. might be have to be set to give a "scrolling" effect. Now's the
  50. time.
  51. If it's not defined, the grid system uses multiple CELL!
  52. calls to clear it. On some devices, this is highly inefficient.
  53. Drivers for those devices should define NEWLINE.
  54. CURSOR! is called whenever we change the cursor's position. If
  55. not implemented, it will be a noop. It is never called with an
  56. out of range "pos" (greater than COLS*LINES).