GEM for ELKS source notes
=========================

Runtime
-------

/bin/gem owns AES, VDI, the display, and input devices.  Clients send one
22-byte request through the stock ELKS AF_UNIX socket at /tmp/gem.aes.  A
client remains blocked while GEM handles its request, so its data segment stays
live without kernel hooks.

Channel zero is Desktop.  Channel one belongs to AES.  Channels two through
five are applications.  A channel routes AES messages and input; it does not
represent an ELKS task or memory allocation.

ELKS owns application creation, scheduling, memory, signals, files, sockets,
and timers.  GEM calls vfork/_execve, waitpid, kill, setitimer, malloc,
_fmemalloc, and the normal file and socket calls directly.

The stock ELKS timer is one-shot.  GEM rearms setitimer after SIGALRM.  PC
text points at the resident BIOS font already used by the ELKS console.
The socket wait is bounded to 20 ms so an alarm delivered during drawing
cannot leave the server asleep with a pending tick. Input and deferred AES
replies continue even if the alarm arrives just before select.

Main files
----------

  src/server/gem_main.c
      AF_UNIX server, ELKS timer, child reaping, and client channels.

  src/server/gem_config.c
      Reads /etc/gem.conf. Environment settings override the file.

  src/aes/gem_exec_elks.c
      Packs a GEM command tail, then calls ELKS vfork and _execve.

  src/aes/gem_aes_resident.c
      AES dispatcher and attached GUI state.

  src/aes/gem_aes_tick.c
      AES timers and input routing to the top window.

  src/aes/gem_pending.c
      Deferred socket replies for events, messages, forms, and mouse tracking.

  src/aes/gem_shell_resident.c
      SHEL_* services.  SHEL_WRITE starts a new ELKS process.

  src/aes/gem_resident_memory.c
      Checked 8086 segment copies while the client is blocked.

  src/aes/gem_far_resource_elks.c
      Direct ELKS paragraph allocation for loaded resources.

  src/desktop/gemdos_posix.c
      Maps the Desktop's DOS-named calls to ELKS filesystem calls.

  src/vdi/
      Resident VDI, input, BIOS font binding, video, mouse, palette, and sound.

  src/vdi/drivers/gem_mouse_serial.c
      Sets the 8250 UART to 7N1 where the ELKS driver only changes baud rate.
      The device number selects COM1 through COM4, including tty symlinks.
      ELKS still owns serial interrupts and the receive queue.

  src/apps/irc/
      Antler IRC state, protocol, interface, and direct ELKS socket transport.
      The default network is Libera Chat in #osdev.

  src/bindings/original/
      Original GEM bindings using the local socket request.

Limits
------

Desktop and four applications can be attached at once.  Event tapes and client
interrupt callbacks are not supported.  The old GEM process and memory calls
are not exposed because ELKS owns those services.
