/*
 * DANG_BEGIN_MODULE
 * 
 * PHASE2 initialization:
 *
 * This is where you initialize anything that adds functionality to DOS.
 * Initialize mfs, ems, xms, the network code, etc. here
 *
 * DANG_END_MODULE
 * 
 * DANG_BEGIN_CHANGELOG
 *
 * $Date: $
 * $Source: $
 * $Revision: $
 * $State: $
 *
 * $Log: $
 *
 * DANG_END_CHANGELOG
 */

#include "dosemu.h"
#include "base/memory.h"
#include "base/int.h"
#include "base/mouse.h"
#include "base/phase.h"
#include "base/misc.h"
#include "base/bios_entry.h"
#include "dosext/ems.h"
#include "dosext/xms.h"
#include "dosext/ipx.h"

/*
 * DANG_BEGIN_FUNCTION phase2_init
 * 
 * description:
 *  Fire up phase 2
 *
 * DANG_END_FUNCTION
 */
void phase2_init(void)
{
#ifdef CONFIG_IPX
  if (config.ipxsup)
    InitIPXFarCallHelper();    /* TRB - initialize IPX in boot() */
#endif

#ifdef CONFIG_V_NET
  pkt_init(0x60);              /* Install the new packet driver interface */
#endif

  ems_init();                /* initialize ems */
  xms_init();                /* initialize xms */
  init_msdos_ints();         /* initialize int 0x21, 0x28, 0x2f, 0xe7 */
}

/*
 * DANG_BEGIN_FUNCTION phase2_init
 * 
 * description:
 *  Fire up phase 2
 *
 * DANG_END_FUNCTION
 */
void phase2_reset(void)
{
  if (mice->intdrv) {
    Bit8u  *ptr;
    Bit16u *seg, *ofs;

    /* this is the mouse handler */
    ptr = (Bit8u *) (Mouse_ADD+12);
    seg = (Bit16u *)((BIOSSEG << 4) + ROM_Mouse_Handler);
    ofs = (Bit16u *)((BIOSSEG << 4) + ROM_Mouse_Handler + 2);

    /* tell the mouse driver where we are...exec add, seg, offset */
    mouse_sethandler(ptr, seg, ofs);
    SETIVEC(0x74, Mouse_SEG, Mouse_ROUTINE_OFF);
    SETIVEC(0x33, Mouse_SEG, Mouse_ROUTINE_OFF);
  }

#if 0
  ems_reset();               /* initialize ems */
  xms_reset();               /* initialize xms */
  msdos_int_reset();         /* initialize int 0x21, 0x28, 0x2f, 0xe7 */
#endif
}

void phase2_term(void)
{
}
