/****************************************************************************/
/*                                                                          */
/*                       IBM/Microsoft Confidential                         */
/*                                                                          */
/*                 Copyright (c) IBM Corporation  1987, 1990                */
/*                 Copyright (c) Microsoft Corp.  1987, 1990                */
/*                           All Rights Reserved                            */
/*                                                                          */
/****************************************************************************/

/*
 * loader.h - definitions for loader.c
 */

// Final physical address of DosHlp routines.  (4K)
#define DOSHLP_PADDR (segtop(DOSHLP_CODESEL))

// Maximum amount of memory that is moved or zeroed in one go.
#define CBMOVEMAX 0x8000

#define MFSDBASE 0x0007c0L   /* lowest MFSD phys address */
#define RIPLBASE 0x000800L   /* lowest RIPL phys address */

//  Kernel header size initially read.
#define CBKERNELHEADERMIN (80*_1K)

//  Real Mode seg, off to far pointer
#define sotofar(seg, off) \
        (((char far *) (((long)(unsigned) (seg)) << 16)) + (unsigned) (off))

//  Real Mode seg, off to physical address
#define sotop(seg, off) \
        ((((long) (unsigned) (seg)) << PARASHIFT) + (unsigned) (off))

//  Real Mode seg to physical address
#define segtop(seg)     sotop(seg, 0)

//  Physical address to Real Mode seg, off
#define ptoseg(p) ((unsigned) ((p) >> PARASHIFT))
#define ptooff(p) ((unsigned) (p) & ((1 << PARASHIFT) - 1))

//  Physical address to Real Mode far pointer
#define ptofar(p) \
                 (((char far *) (((long) (p) << 12) & 0xffff0000L)) + ptooff(p))

//  Fetch short or long through a far pointer
#define ptoshort(p) (*(unsigned short far *) (p))
#define ptolong(p)  (*(unsigned long far *) (p))

//  Paragraph address to physical frame number
#define segtof(seg) \
            ((unsigned long) (unsigned short) (seg) >> (PAGESHIFT - PARASHIFT))

//  Physical frame number to paragraph address
#define ftoseg(f) ((unsigned short) ((f) << (PAGESHIFT - PARASHIFT)))

//  Physical frame number to real mode far pointer
#define ftofar(f) (sotofar(ftoseg(f), 0))

//  Round a physical address or size up to the next multiple of PAGESIZE
#define PAGEROUND(p)    (((p) + PAGEMASK) & ~PAGEMASK)

//  Round a physical address or size up to the next multiple of PARASIZE
#define PARAROUND(p)    (((p) + PARAMASK) & ~PARAMASK)

//  Get page boundary above physical address
#define BYTESTOPAGE(cb) (((cb) + PAGEMASK) >> PAGESHIFT)

//  Round a physical address or size up to the next multiple of SECTSIZE
#define SECTROUND(p)    (((p) + SECTMASK) & ~SECTMASK)

#define ARENASIZE       (PAGESIZE / sizeof(struct arena_s)) /* # of ArenaInfo
								entries */
#define SELINCR         8       /* selector increment */
#define KSHIFT          10      /* 1k shift count */

unsigned short FindFunction( unsigned char,
                             unsigned char,
                             EisaFuncInfo *,
                             unsigned );

unsigned short CountMemory( void );

unsigned short MakeEisaArena( struct arena_s *,
                              unsigned short );

void SortArena( struct arena_s *,
                unsigned short );

void InsertArena( struct arena_s *,
                  unsigned short,
                  struct arena_s * );

void DeleteArena( struct arena_s *,
                  unsigned short,
                  struct arena_s * );

void GetSlotInfo( unsigned char,
                  EisaSlotInfo * );

void GetFunctionInfo( unsigned char,
                      unsigned char,
                      EisaFuncInfo * );
