2000-05-06 21:34:20 +02:00
|
|
|
/****************************************************************/
|
|
|
|
/* */
|
|
|
|
/* pcb.h */
|
|
|
|
/* */
|
|
|
|
/* Process Control and Interrupt data structures */
|
|
|
|
/* */
|
|
|
|
/* November 26, 1991 */
|
|
|
|
/* */
|
|
|
|
/* Copyright (c) 1995 */
|
|
|
|
/* Pasquale J. Villani */
|
|
|
|
/* All Rights Reserved */
|
|
|
|
/* */
|
|
|
|
/* This file is part of DOS-C. */
|
|
|
|
/* */
|
|
|
|
/* DOS-C is free software; you can redistribute it and/or */
|
|
|
|
/* modify it under the terms of the GNU General Public License */
|
|
|
|
/* as published by the Free Software Foundation; either version */
|
|
|
|
/* 2, or (at your option) any later version. */
|
|
|
|
/* */
|
|
|
|
/* DOS-C is distributed in the hope that it will be useful, but */
|
|
|
|
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
|
|
|
|
/* the GNU General Public License for more details. */
|
|
|
|
/* */
|
|
|
|
/* You should have received a copy of the GNU General Public */
|
|
|
|
/* License along with DOS-C; see the file COPYING. If not, */
|
|
|
|
/* write to the Free Software Foundation, 675 Mass Ave, */
|
|
|
|
/* Cambridge, MA 02139, USA. */
|
|
|
|
/****************************************************************/
|
|
|
|
|
2000-08-06 06:18:21 +02:00
|
|
|
/***************************************************************
|
|
|
|
2000/03/22 ska
|
|
|
|
There is a newly documented (though used previously) side effect
|
|
|
|
of the definitions and assumptions made herein:
|
|
|
|
The assembly sources may use a macro named "PUSH$ALL" to push
|
|
|
|
all processor registers onto the stack, see example below:
|
|
|
|
PUSH$ALL
|
|
|
|
mov ax, sp
|
|
|
|
...
|
|
|
|
push ax
|
|
|
|
call _c_function
|
|
|
|
pop cx
|
|
|
|
The stack pointer immediately after the PUSH$ALL macro shall point to
|
|
|
|
a structure used as an "iregs" structure within the C language.
|
|
|
|
Therefore the internal of the structure "iregs" _must_ always
|
|
|
|
match the implementation of the macro "PUSH$ALL".
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PCB_H
|
|
|
|
#define __PCB_H
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
#ifdef MAIN
|
|
|
|
#ifdef VERSION_STRINGS
|
2001-11-18 15:01:12 +01:00
|
|
|
static BYTE *pcb_hRcsId =
|
|
|
|
"$Id$";
|
2000-05-06 21:34:20 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2000-08-06 06:18:21 +02:00
|
|
|
/* Force one-byte alignment for all the internal structures, see above */
|
|
|
|
#include <algnbyte.h>
|
2000-05-06 21:34:20 +02:00
|
|
|
/* */
|
|
|
|
/* interrupt handler structure definition */
|
|
|
|
/* */
|
2001-11-18 15:01:12 +01:00
|
|
|
typedef union {
|
2000-05-06 21:34:20 +02:00
|
|
|
UWORD x; /* access mode for ax, bx, etc. */
|
2001-11-18 15:01:12 +01:00
|
|
|
struct {
|
2000-05-06 21:34:20 +02:00
|
|
|
UBYTE l; /* access mode for al, bl, etc. */
|
|
|
|
UBYTE h; /* access mode for ah, bh, etc. */
|
2001-11-18 15:01:12 +01:00
|
|
|
} b;
|
|
|
|
} xreg;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2000-08-06 06:18:21 +02:00
|
|
|
/* The structure assumes that:
|
|
|
|
1) An interrupt was invoked, &
|
|
|
|
2) the PUSH$ALL macro was invoked immediately after that.
|
|
|
|
Furthermore, the PUSH$ALL macro must push ES first and AX last.
|
|
|
|
-- 2000/03/22 ska*/
|
2000-05-06 21:34:20 +02:00
|
|
|
/* maps MS-DOS unique stacking order */
|
2001-11-18 15:01:12 +01:00
|
|
|
typedef struct _iregss {
|
|
|
|
xreg a, b, c, d;
|
|
|
|
UWORD si, di, bp, ds, es;
|
|
|
|
UWORD ip, cs, flags;
|
|
|
|
} iregs;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2002-08-03 06:08:58 +02:00
|
|
|
/* struct used for local copy of registers */
|
|
|
|
typedef struct {
|
|
|
|
xreg a, b, c, d;
|
|
|
|
UWORD si, di, ds, es;
|
|
|
|
} lregs;
|
|
|
|
|
2000-08-06 06:18:21 +02:00
|
|
|
/* Registers directly passed to syscall;
|
2001-11-18 15:01:12 +01:00
|
|
|
must be the same order as iregs!
|
|
|
|
Is used to define parameters. */
|
2000-08-06 06:18:21 +02:00
|
|
|
#define DIRECT_IREGS \
|
|
|
|
xreg a, xreg b, xreg c, xreg d, \
|
|
|
|
UWORD si, UWORD di, UWORD bp, UWORD ds, UWORD es, \
|
|
|
|
UWORD ip, UWORD cs, UWORD flags
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* Process control block for task switching */
|
2001-11-18 15:01:12 +01:00
|
|
|
typedef struct {
|
2000-05-06 21:34:20 +02:00
|
|
|
UWORD pc_ss;
|
|
|
|
UWORD pc_sp;
|
|
|
|
iregs pc_regs;
|
2001-11-18 15:01:12 +01:00
|
|
|
} pcb;
|
2000-05-06 21:34:20 +02:00
|
|
|
|
2000-08-06 06:18:21 +02:00
|
|
|
/* Note: The following figure is not made by myself and I assume that
|
|
|
|
the order of "ES" through "AX" are misinterpreted?! -- 2000/03/22 ska*/
|
|
|
|
|
2000-05-06 21:34:20 +02:00
|
|
|
/* For MSC, the following offsets must match the assembly process */
|
|
|
|
/* support offsets */
|
|
|
|
/* NOTE: Alignemnts must be set to 1 (-Zp1) */
|
|
|
|
/* ss: 0 */
|
|
|
|
/* sp: 2 */
|
|
|
|
/* es: 4 */
|
|
|
|
/* ds: 6 */
|
|
|
|
/* di: 8 */
|
|
|
|
/* si: 10 */
|
|
|
|
/* bp: 12 */
|
|
|
|
/* sp: 14 NOTE: not used in this structure */
|
|
|
|
/* bx: 16 */
|
|
|
|
/* dx: 18 */
|
|
|
|
/* cx: 20 */
|
|
|
|
/* ax: 22 */
|
|
|
|
/* ip: 24 */
|
|
|
|
/* cs: 26 */
|
|
|
|
/* flags: 28 */
|
|
|
|
/* */
|
|
|
|
/* For Borland C, the following offsets must match the assembly process */
|
|
|
|
/* support offsets */
|
|
|
|
/* ss: 0 */
|
|
|
|
/* sp: 2 */
|
|
|
|
/* bp: 4 */
|
|
|
|
/* di: 6 */
|
|
|
|
/* si: 8 */
|
|
|
|
/* ds: 10 */
|
|
|
|
/* es: 12 */
|
|
|
|
/* dx: 14 */
|
|
|
|
/* cx: 16 */
|
|
|
|
/* bx: 18 */
|
|
|
|
/* ax: 20 */
|
|
|
|
/* ip: 22 */
|
|
|
|
/* cs: 24 */
|
|
|
|
/* flags: 26 */
|
|
|
|
|
|
|
|
#define BP bp
|
|
|
|
#define DI di
|
|
|
|
#define SI si
|
|
|
|
#define DS ds
|
|
|
|
#define ES es
|
|
|
|
#define DX d.x
|
|
|
|
#define CX c.x
|
|
|
|
#define BX b.x
|
|
|
|
#define AX a.x
|
|
|
|
#define DH d.b.h
|
|
|
|
#define CH c.b.h
|
|
|
|
#define BH b.b.h
|
|
|
|
#define AH a.b.h
|
|
|
|
#define DL d.b.l
|
|
|
|
#define CL c.b.l
|
|
|
|
#define BL b.b.l
|
|
|
|
#define AL a.b.l
|
|
|
|
#define IP ip
|
|
|
|
#define CS cs
|
|
|
|
#define FLAGS flags
|
|
|
|
|
|
|
|
#define FLG_ZERO 0x0040
|
|
|
|
#define FLG_CARRY 0x0001
|
2000-08-06 06:18:21 +02:00
|
|
|
|
|
|
|
/* Allow default alignment from now on */
|
|
|
|
#include <algndflt.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|