pmapi.h

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

H
1,149
字号
#endif

/* {secret} Pointer to global exports structure.
 * Should not be used by application programs.
 */
extern PM_imports _VARAPI _PM_imports;

/* {secret} */
extern void * (*__PM_malloc)(size_t size);
/* {secret} */
extern void * (*__PM_calloc)(size_t nelem,size_t size);
/* {secret} */
extern void * (*__PM_realloc)(void *ptr,size_t size);
/* {secret} */
extern void (*__PM_free)(void *p);

/*--------------------------- Function Prototypes -------------------------*/

/* Routine to initialise the host side PM library. Note used from DLL's */

void    PMAPI PM_init(void);

/* Routine to return either PM_realMode, PM_286 or PM_386 */

int     PMAPI PM_getModeType(void);

/* Routine to return a selector to the BIOS data area at segment 0x40 */

void *  PMAPI PM_getBIOSPointer(void);

/* Routine to return a linear pointer to the VGA frame buffer memory */

void *  PMAPI PM_getA0000Pointer(void);

/* Routines to map/free physical memory into the current DS segment. In
 * some environments (32-bit DOS is one), after the mapping has been
 * allocated, it cannot be freed. Hence you should only allocate the
 * mapping once and cache the value for use by other parts of your
 * application. If the mapping cannot be createed, this function will
 * return a NULL pointer.
 *
 * This routine will also work for memory addresses below 1Mb, but the
 * mapped address cannot cross the 1Mb boundary.
 */

void *  PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached);
void    PMAPI PM_freePhysicalAddr(void *ptr,ulong limit);

/* Routine to determine the physical address of a linear address. It is
 * up to the caller to ensure the entire address range for a linear
 * block of memory is page aligned if that is required.
 */

ulong   PMAPI PM_getPhysicalAddr(void *p);
ibool   PMAPI PM_getPhysicalAddrRange(void *p,ulong length,ulong *physAddress);

/* Routines for memory allocation. By default these functions use the regular
 * C runtime library malloc/free functions, but you can use the
 * PM_useLocalMalloc function to override the default memory allocator with
 * your own memory allocator. This will ensure that all memory allocation
 * used by SciTech products will use your overridden memory allocator
 * functions.
 *
 * Note that BPD files automatically map the C runtime library
 * malloc/calloc/realloc/free calls from inside the BPD to the PM library
 * versions by default.
 */

void    PMAPI PM_useLocalMalloc(void * (*malloc)(size_t size),void * (*calloc)(size_t nelem,size_t size),void * (*realloc)(void *ptr,size_t size),void (*free)(void *p));
void *  PMAPI PM_malloc(size_t size);
void *  PMAPI PM_calloc(size_t nelem,size_t size);
void *  PMAPI PM_realloc(void *ptr,size_t size);
void    PMAPI PM_free(void *p);

/* Routine to allocate a memory block in the global shared region that
 * is common to all tasks and accessible from ring 0 code.
 */

void *  PMAPI PM_mallocShared(long size);

/* Routine to free the allocated shared memory block */

void    PMAPI PM_freeShared(void *ptr);

/* Attach a previously allocated linear mapping to a new process */

void *  PMAPI PM_mapToProcess(void *linear,ulong limit);

/* Macros to extract byte, word and long values from a char pointer */

#define PM_getByte(p)       *((volatile uchar*)(p))
#define PM_getWord(p)       *((volatile ushort*)(p))
#define PM_getLong(p)       *((volatile ulong*)(p))
#define PM_setByte(p,v)     PM_getByte(p) = (v)
#define PM_setWord(p,v)     PM_getWord(p) = (v)
#define PM_setLong(p,v)     PM_getLong(p) = (v)

/* Routine for accessing a low 1Mb memory block. You dont need to free this
 * pointer, but in 16 bit protected mode the selector allocated will be
 * re-used the next time this routine is called.
 */

void *  PMAPI PM_mapRealPointer(uint r_seg,uint r_off);

/* Routine to allocate a block of conventional memory below the 1Mb
 * limit so that it can be accessed from real mode. Ensure that you free
 * the segment when you are done with it.
 *
 * This routine returns a selector and offset to the segment that has been
 * allocated, and also returns the real mode segment and offset which can
 * be passed to real mode routines. Will return 0 if memory could not be
 * allocated.
 *
 * Please note that with some DOS extenders, memory allocated with the
 * following function cannot be freed, hence it will be allocated for the
 * life of your program. Thus if you need to call a bunch of different
 * real-mode routines in your program, allocate a single large buffer at
 * program startup that can be re-used throughout the program execution.
 */

void *  PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off);
void    PMAPI PM_freeRealSeg(void *mem);

/* Routine to allocate a block of locked memory, and return both the
 * linear and physical addresses of the memory. You should always
 * allocate locked memory blocks in page sized chunks (ie: 4K on IA32).
 * If the memory is not contiguous, you will need to use the
 * PM_getPhysicalAddr function to get the physical address of linear
 * pages within the memory block (the returned physical address will be
 * for the first address in the memory block only).
 */

void *  PMAPI PM_allocLockedMem(uint size,ulong *physAddr,ibool contiguous,ibool below16Meg);
void    PMAPI PM_freeLockedMem(void *p,uint size,ibool contiguous);

/* Routine to allocate and free paged sized blocks of shared memory.
 * Addressable from all processes, but not from a ring 0 context
 * under OS/2. Note that under OS/2 PM_mapSharedPages must be called
 * to map the memory blocks into the shared memory address space
 * of each connecting process.
 */

void *  PMAPI PM_allocPage(ibool locked);
void    PMAPI PM_freePage(void *p);
#ifdef __OS2__
void    PMAPI PM_mapSharedPages(void);
#endif

/* Routine to return true if we have access to the BIOS on the host OS */

ibool   PMAPI PM_haveBIOSAccess(void);

/* Routine to call a real mode assembly language procedure. Register
 * values are passed in and out in the 'regs' and 'sregs' structures. We
 * do not provide any method of copying data from the protected mode stack
 * to the real mode stack, so if you need to pass data to real mode, you will
 * need to write a real mode assembly language hook to recieve the values
 * in registers, and to pass the data through a real mode block allocated
 * with the PM_allocRealSeg() routine.
 */

void    PMAPI PM_callRealMode(uint seg,uint off, RMREGS *regs,RMSREGS *sregs);

/* Routines to generate real mode interrupts using the same interface that
 * is used by int86() and int86x() in realmode. This routine is need to
 * call certain BIOS and DOS functions that are not supported by some
 * DOS extenders. No translation is done on any of the register values,
 * so they must be correctly set up and translated by the calling program.
 *
 * Normally the DOS extenders will allow you to use the normal int86()
 * function directly and will pass on unhandled calls to real mode to be
 * handled by the real mode handler. However calls to int86x() with real
 * mode segment values to be loaded will cause a GPF if used with the
 * standard int86x(), so you should use these routines if you know you
 * want to call a real mode handler.
 */

int     PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out);
int     PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out,RMSREGS *sregs);

/* Routine to generate a real mode interrupt. This is identical to the
 * above function, but takes a DPMI_regs structure for the registers
 * which has a lot more information. It is only available from 32-bit
 * protected mode.
 */

void    PMAPI DPMI_int86(int intno, DPMI_regs *regs);

/* Function to return the amount of available physical and total memory.
 * The results of this function are *only* valid before you have made any
 * calls to malloc() and free(). If you need to keep track of exactly how
 * much memory is currently allocated, you need to call this function to
 * get the total amount of memory available and then keep track of
 * the available memory every time you call malloc() and free().
 */

void    PMAPI PM_availableMemory(ulong *physical,ulong *total);

/* Return the address of a global VESA real mode transfer buffer for use
 * by applications.
 */

void *  PMAPI PM_getVESABuf(uint *len,uint *rseg,uint *roff);

/* Handle fatal error conditions */

void    PMAPI PM_fatalError(const char *msg);

/* Function to set a cleanup error handler called when PM_fatalError
 * is called. This allows us to the console back into a normal state
 * if we get a failure from deep inside a BPD file. This function is
 * not exported to BPD files, and is only used by code compiled for the
 * OS.
 */

void    PMAPI PM_setFatalErrorCleanup(PM_fatalCleanupHandler cleanup);

/* Return the OS type flag as defined in <drvlib/os/os.h> */

long    PMAPI PM_getOSType(void);

/* Functions to set a VBE bank via an Int 10h */

void    PMAPI PM_setBankA(int bank);
void    PMAPI PM_setBankAB(int bank);
void    PMAPI PM_setCRTStart(int x,int y,int waitVRT);

/* Return the current working directory */

char *  PMAPI PM_getCurrentPath(char *path,int maxLen);

/* Return paths to the VBE/AF and Nucleus directories */

const char * PMAPI PM_getVBEAFPath(void);
const char * PMAPI PM_getNucleusPath(void);
const char * PMAPI PM_getNucleusConfigPath(void);

/* Find the path to a binary portable DLL */

void    PMAPI PM_setLocalBPDPath(const char *path);
ibool   PMAPI PM_findBPD(const char *dllname,char *bpdpath);

/* Returns the drive letter of the boot drive for DOS, OS/2 and Windows */

char    PMAPI PM_getBootDrive(void);

/* Return a network unique machine identifier as a string */

const char * PMAPI PM_getUniqueID(void);

/* Return the network machine name as a string */

const char * PMAPI PM_getMachineName(void);

/* Functions to install and remove the virtual linear framebuffer
 * emulation code. For unsupported DOS extenders and when running under
 * a DPMI host like Windows or OS/2, this function will return a NULL.
 */

ibool   PMAPI VF_available(void);
void *  PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc);
void    PMAPI VF_exit(void);

/* Functions to wait for a keypress and read a key for command line
 * environments such as DOS, Win32 console and Unix.
 */

int     PMAPI PM_kbhit(void);
int     PMAPI PM_getch(void);

/* Functions to create either a fullscreen or windowed console on the
 * desktop, and to allow the resolution of fullscreen consoles to be
 * changed on the fly without closing the console. For non-windowed
 * environments (such as a Linux or OS/2 fullscreen console), these
 * functions enable console graphics mode and restore console text mode.
 *
 * The suspend application callback is used to allow the application to
 * save the state of the fullscreen console mode to allow temporary
 * switching to another console or back to the regular GUI desktop. It
 * is also called to restore the fullscreen graphics state after the
 * fullscreen console regains the focus.
 *
 * The device parameter allows for the console to be opened on a different
 * display controllers (0 is always the primary controller).
 */

PM_HWND PMAPI PM_openConsole(PM_HWND hwndUser,int device,int xRes,int yRes,int bpp,ibool fullScreen);
int     PMAPI PM_getConsoleStateSize(void);

⌨️ 快捷键说明

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