#ifndef __DAEMON_H__
#define __DAEMON_H__

/* 
 * Copyright (C) 1995 under GPL: Wayne Meissner
 * 
 * $Author: wayne $
 * $Date: 1995/01/17 14:25:36 $
 * $Source: /home/wayne/src/dosemu/daemon/RCS/daemon.h,v $
 * $Revision: 2.2 $
 * 
 */

/* daemon.h 
 * defines and structs for the daemon
 * 
 * Commands are as follows:
 * 0 - 99     common to dosemu and dos server program
 * 100 - 199  common to dosemu and linux client program
 * 1000 -     common to dos server program and linux client program
 */

#include "dosdmn.h"
/* dosemu < - > dos server */
#define DAEMON_FN(fn)   (DAEMON_AL | ((fn) << 8))
#define DAEMON_INIT     0 /* only used on startup */
#define DAEMON_INITFN   DAEMON_FN(DAEMON_INIT) /* 0x0066 */
#define DAEMON_REPLY    1 /* reply to the client */
#define DAEMON_IDLEDOS  2 /* idle dosemu */
#define DAEMON_WAITCONN 3 /* wait for a client connection */
#define DAEMON_EXIT     4 /* exit the dos server program */
#define DAEMON_RETRY    5 /* retry last command */
#define DAEMON_RESERVED 6 /* not to be used */
#define DAEMON_DOCMD    7 /* call dos_helper command */
#define DAEMON_WAITCLIENT 8 /* wait for a client command */

/* linux client <-> dos server */
#define DAEMON_RUNDOS  101 /* run dos for a while. arg is number of cpu cycles */
#define DAEMON_SPAWN   102 /* run a dos program */
#define DAEMON_EXEC    103 /* similar to DAEMON_SPAWN */
#define DAEMON_INT86   104 /* call a dos interrupt */
#define DAEMON_MALLOC  105 /* allocate memory in ds */
#define DAEMON_OUTB    106 /* write a byte to a port */
#define DAEMON_INB     107 /* get a byte from a port */
#define DAEMON_PEEK    108 /* peek at a memory location */
#define DAEMON_POKE    109 /* poke a value into memory */
#define DAEMON_CLI     110 /* clear interrupts */
#define DAEMON_STI     111 /* restart interrupts */
#define DAEMON_FREE    112 /* free memory obtained with DAEMON_MALLOC */
#define DAEMON_GETBUF  501 /* SPECIAL HACK */

/* linux client < - > dosemu */
#define DAEMON_GETMEM  1001 /* get data from a region of dos memory */
#define DAEMON_PUTMEM  1002 /* put "    to   "   "    "   "   " */
#define DAEMON_CLIENTEXIT 1003 /* client telling dosemu that it is finished */

/* compatibility */
#define INIT_DAEMON  DAEMON_INIT 
#define REPLY_DAEMON DAEMON_REPLY 
#define RUN_DOS      DAEMON_RUNDOS
/* stuff from dosemu */
#define CALL_IRQ    DAEMON_INT86  /* call an IRQ */
#define ALLOC_MEM   DAEMON_MALLOC /* allocate a buffer */
#define DO_CMD      DAEMON_DOCMD  /* do a dosemu command */
#define EXIT_DAEMON DAEMON_EXIT   /* exit back to dos */

/* stuff between client and dosemu */
#define READ_DATA 100 /* no longer needed */

#include "x86.h"

/* the dosemu function number */



#ifdef __GNUC__
#include "system.h"
#else
#define int16 int
#define uint16 unsigned int
#endif

struct daemon_comms {
  uint16 seg;     /* segment containing the struct */
  uint16 off;     /* offset of the struct into the segment */
  uint16 command; /* command to do */
  uint16 arg;     /* argument to command */
  uint16 ax;  /* backup copy of ax */
  char buf[1024]; /* hopefully enuff for some temporory data */
};


#endif /* __DAEMON_H__ */
