pmapi.h

来自「适合KS8695X」· C头文件 代码 · 共 1,149 行 · 第 1/4 页

H
1,149
字号
/****************************************************************************
*
*                   SciTech OS Portability Manager Library
*
*  ========================================================================
*
*    The contents of this file are subject to the SciTech MGL Public
*    License Version 1.0 (the "License"); you may not use this file
*    except in compliance with the License. You may obtain a copy of
*    the License at http://www.scitechsoft.com/mgl-license.txt
*
*    Software distributed under the License is distributed on an
*    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
*    implied. See the License for the specific language governing
*    rights and limitations under the License.
*
*    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
*
*    The Initial Developer of the Original Code is SciTech Software, Inc.
*    All Rights Reserved.
*
*  ========================================================================
*
* Language:     ANSI C
* Environment:  Any
*
* Description:  Header file for the OS Portability Manager Library, which
*               contains functions to implement OS specific services in a
*               generic, cross platform API. Porting the OS Portability
*               Manager library is the first step to porting any SciTech
*               products to a new platform.
*
****************************************************************************/

#ifndef __PMAPI_H
#define __PMAPI_H

#include "scitech.h"
#include "pcilib.h"
#include "ztimerc.h"
#if !defined(__WIN32_VXD__) && !defined(__OS2_VDD__) && !defined(__NT_DRIVER__)
#include <stdio.h>
#include <stdlib.h>
#endif

/*--------------------------- Macros and Typedefs -------------------------*/

/* You will need to define one of the following before you compile this
 * library for it to work correctly with the DOS extender that you are
 * using when compiling for extended DOS:
 *
 *      TNT         - Phar Lap TNT DOS Extender
 *      DOS4GW      - Rational DOS/4GW, DOS/4GW Pro, Causeway and PMODE/W
 *      DJGPP       - DJGPP port of GNU C++
 *
 * If none is specified, we will automatically determine which operating
 * system is being targetted and the following will be defined (provided by
 * scitech.h header file):
 *
 *      __MSDOS16__     - Default for 16 bit MSDOS mode
 *      __MSDOS32__     - Default for 32 bit MSDOS
 *      __WINDOWS16__   - Default for 16 bit Windows
 *      __WINDOWS32__   - Default for 32 bit Windows
 *
 * One of the following will be defined automatically for you to select
 * which memory model is in effect:
 *
 *      REALMODE    - 16 bit real mode (large memory model)
 *      PM286       - 16 protected mode (large memory model)
 *      PM386       - 32 protected mode (flat memory model)
 */

#if defined(__UNIX__) && !defined(_MAX_PATH)
#define _MAX_PATH 256
#endif

#if defined(TNT) || defined(DOSX) || defined(X32VM) || defined(DPMI32)      \
    || defined(DOS4GW) || defined(DJGPP) || defined(__WINDOWS32__)          \
    || defined(__MSDOS32__) || defined(__UNIX__) || defined(__WIN32_VXD__) \
    || defined(__32BIT__) || defined(__SMX32__) || defined(__RTTARGET__)
#define PM386
#elif defined(DPMI16) || defined(__WINDOWS16__)
#define PM286
#else
#define REALMODE
#endif

#pragma pack(1)

/* Provide the typedefs for the PM_int386 functions, which issue native
 * interrupts in real or protected mode and can pass extended registers
 * around.
 */

struct _PMDWORDREGS {
    ulong   eax,ebx,ecx,edx,esi,edi,cflag;
    };

struct _PMWORDREGS {
    ushort  ax,ax_hi;
    ushort  bx,bx_hi;
    ushort  cx,cx_hi;
    ushort  dx,dx_hi;
    ushort  si,si_hi;
    ushort  di,di_hi;
    ushort  cflag,cflag_hi;
    };

struct _PMBYTEREGS {
    uchar   al, ah; ushort ax_hi;
    uchar   bl, bh; ushort bx_hi;
    uchar   cl, ch; ushort cx_hi;
    uchar   dl, dh; ushort dx_hi;
    };

typedef union {
    struct  _PMDWORDREGS e;
    struct  _PMWORDREGS  x;
    struct  _PMBYTEREGS  h;
    } PMREGS;

typedef struct {
    ushort  es;
    ushort  cs;
    ushort  ss;
    ushort  ds;
    ushort  fs;
    ushort  gs;
    } PMSREGS;

/* Provide definitions for the real mode register structures passed to
 * the PM_int86() and PM_int86x() routines. Note that we provide our own
 * functions to do this for 16-bit code that calls the PM_int386 functions.
 */

typedef PMREGS  RMREGS;
typedef PMSREGS RMSREGS;

typedef struct {
    long    edi;
    long    esi;
    long    ebp;
    long    reserved;
    long    ebx;
    long    edx;
    long    ecx;
    long    eax;
    short   flags;
    short   es,ds,fs,gs,ip,cs,sp,ss;
    } DPMI_regs;

#ifdef  __MSDOS__
/* Register structure passed to PM_VxDCall function */
typedef struct {
    ulong   eax;
    ulong   ebx;
    ulong   ecx;
    ulong   edx;
    ulong   esi;
    ulong   edi;
    ushort  ds,es;
    } VXD_regs;
#endif

#define PM_MAX_DRIVE                3
#define PM_MAX_PATH                 256
#define PM_FILE_INVALID             (void*)0xFFFFFFFF

/* Structure for generic directory traversal and management. Also the same
 * values are passed to PM_setFileAttr to change the file attributes.
 */

typedef struct {
    ulong   dwSize;
    ulong   attrib;
    ulong   sizeLo;
    ulong   sizeHi;
    char    name[PM_MAX_PATH];
    } PM_findData;

/* Macro to compute the byte offset of a field in a structure of type type */

#define PM_FIELD_OFFSET(type,field) ((long)&(((type*)0)->field))

/* Marcto to compute the address of the base of the structure given its type,
 * and an address of a field within the structure.
 */

#define PM_CONTAINING_RECORD(address, type, field)      \
    ((type*)(                                           \
    (char*)(address) -                                  \
    (char*)(&((type*)0)->field)))

/* Flags stored in the PM_findData structure, and also values passed to
 * PM_setFileAttr to change the file attributes.
 */

#define PM_FILE_NORMAL              0x00000000
#define PM_FILE_READONLY            0x00000001
#define PM_FILE_DIRECTORY           0x00000002
#define PM_FILE_ARCHIVE             0x00000004
#define PM_FILE_HIDDEN              0x00000008
#define PM_FILE_SYSTEM              0x00000010

/* Flags returned by the PM_splitpath function */

#define PM_HAS_WILDCARDS 0x01
#define PM_HAS_EXTENSION 0x02
#define PM_HAS_FILENAME  0x04
#define PM_HAS_DIRECTORY 0x08
#define PM_HAS_DRIVE     0x10

/* Structure passed to the PM_setFileTime functions */
typedef struct {
    short   sec;        /* Seconds */
    short   min;        /* Minutes */
    short   hour;       /* Hour (0--23) */
    short   day;        /* Day of month (1--31) */
    short   mon;        /* Month (0--11) */
    short   year;       /* Year (calendar year minus 1900) */
    } PM_time;

/* Define a macro for creating physical base addresses from segment:offset */

#define MK_PHYS(s,o)  (((ulong)(s) << 4) + (ulong)(o))

/* Define the different types of modes supported. This is a global variable
 * that can be used to determine the type at runtime which will contain
 * one of these values.
 */

typedef enum {
    PM_realMode,
    PM_286,
    PM_386
    } PM_mode_enum;

/* Define types passed to PM_enableWriteCombine */

#define PM_MTRR_UNCACHABLE  0
#define PM_MTRR_WRCOMB      1
#define PM_MTRR_WRTHROUGH   4
#define PM_MTRR_WRPROT      5
#define PM_MTRR_WRBACK      6
#define PM_MTRR_MAX         6

/* Error codes returned by PM_enableWriteCombine */

#define PM_MTRR_ERR_OK                  0
#define PM_MTRR_NOT_SUPPORTED           -1
#define PM_MTRR_ERR_PARAMS              -2
#define PM_MTRR_ERR_NOT_4KB_ALIGNED     -3
#define PM_MTRR_ERR_BELOW_1MB           -4
#define PM_MTRR_ERR_NOT_ALIGNED         -5
#define PM_MTRR_ERR_OVERLAP             -6
#define PM_MTRR_ERR_TYPE_MISMATCH       -7
#define PM_MTRR_ERR_NONE_FREE           -8
#define PM_MTRR_ERR_NOWRCOMB            -9
#define PM_MTRR_ERR_NO_OS_SUPPORT       -10

/* Values passed to the PM_DMACProgram function */

#define PM_DMA_READ_ONESHOT     0x44    /* One-shot DMA read        */
#define PM_DMA_WRITE_ONESHOT    0x48    /* One-shot DMA write       */
#define PM_DMA_READ_AUTOINIT    0x54    /* Auto-init DMA read       */
#define PM_DMA_WRITE_AUTOINIT   0x58    /* Auto-init DMA write      */

/* Flags passed to suspend application callback */

#define PM_DEACTIVATE       1
#define PM_REACTIVATE       2

/* Return codes that the application can return from the suspend application
 * callback registered with the PM library. See the MGL documentation for
 * more details.
 */
#define PM_SUSPEND_APP      0
#define PM_NO_SUSPEND_APP   1

/****************************************************************************
REMARKS:
This enumeration defines the type values passed to the PM_agpReservePhysical
function, to define how the physical memory mapping should be handled.

The PM_agpUncached type indicates that the memory should be allocated as
uncached memory.

The PM_agpWriteCombine type indicates that write combining should be enabled

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?