Ejemplo n.º 1
0
static void fillrow(int row, int left, int right, int fill)
{
  int col;
  short filler[right-left+1];
  
  for (col = left; col <= right; col++)
    filler[col-left] = fill;
  dosmemput(filler, (right-left+1)*2, VIDADDR(row, left));
}
Ejemplo n.º 2
0
/* clear_hard_error - clear any indication of a critical error
 */
void clear_hard_error(void)
{
    short zero = 0;

    if(handler_installed)
        dosmemput(&zero, 2, new_handler_info.rm_segment * 16 + 14);
    hard_error_occurred = 0;
    return;
}
Ejemplo n.º 3
0
void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
{
    int j;

    PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));

    if (pdc_direct_video)
    {
#if SMALL || MEDIUM
# ifndef __PACIFIC__
        struct SREGS segregs;
# endif
        int ds;
#endif
        /* this should be enough for the maximum width of a screen */

        struct {unsigned char text, attr;} temp_line[256];

        /* replace the attribute part of the chtype with the actual
           color value for each chtype in the line */

        for (j = 0; j < len; j++)
        {
            chtype ch = srcp[j];

            temp_line[j].attr = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
#ifdef CHTYPE_LONG
            if (ch & A_ALTCHARSET && !(ch & 0xff80))
                ch = acs_map[ch & 0x7f];
#endif
            temp_line[j].text = ch & 0xff;
        }

#ifdef __DJGPP__
        dosmemput(temp_line, len * 2,
                  (unsigned long)_FAR_POINTER(pdc_video_seg,
                  pdc_video_ofs + (lineno * curscr->_maxx + x) * 2));
#else
# if SMALL || MEDIUM
#  ifdef __PACIFIC__
        ds = FP_SEG((void far *) temp_line);
#  else
        segread(&segregs);
        ds = segregs.ds;
#  endif
        movedata(ds, (int)temp_line, pdc_video_seg,
                 pdc_video_ofs + (lineno * curscr->_maxx + x) * 2, len * 2);
# else
        memcpy((void *)_FAR_POINTER(pdc_video_seg,
               pdc_video_ofs + (lineno * curscr->_maxx + x) * 2),
               temp_line, len * 2);
# endif
#endif

    }
    else
        for (j = 0; j < len;)
Ejemplo n.º 4
0
// cd_sendrequest: Sends an IOCTL request to the driver.
// Pass the drive number
void cd_sendrequest(int drivlab, CD_DEVINFO * reqbuf)
{
  rrr.x.ax = 0x1510;
  rrr.x.cx = drivlab;
  SET_TB_ESBX dosmemput(reqbuf, reqbuf->size, __tb);
  __dpmi_int(0x2f, &rrr);
  dosmemget(__tb, reqbuf->size, reqbuf);
  cd_lasterror = reqbuf->status;
}
Ejemplo n.º 5
0
dsk_err_t int25_rdwr(int rdwr, INT25_PACKET *pkt)
{
	long addr;
	__dpmi_regs regs;
	int try_bigdrive = 1;

/* INT 25 and INT 26 leave a word on the stack, which makes it awkward to
 * call them directly using int86() or __dpmi_int(). So call this trampoline
 * which handles the stack weirdness. */
	unsigned char code16[] = 
	{
		0xCC, //0x55, 		/* push bp */
		0x8B, 0xEC,	/* mov bp,sp */
		0xCD, 0x25,	/* INT 25 */
		0x8B, 0xE5,	/* mov sp,bp */
		0x90, //0x5D,		/* pop bp */
		0xCB		/* retf */
	};
	code16[4] = (rdwr & 0xFF);	/* Interrupt to call */
	dosmemput(code16, sizeof(code16), __tb + 16);

	memset(&regs, 0, sizeof(regs));

/*	{
		unsigned char buf[1024];
		dosmemget(__tb, 1024, buf);
		fprintf(stderr, "Packet: %04lx %02x %p\n",
			pkt->sector, pkt->count, pkt->buf);
		dosmemput(buf, 1024, __tb);
	} */

	if (pkt->sector < 65536L)
	{
		regs.x.ax = (rdwr >> 8);
		regs.x.cx = pkt->count;
		regs.x.dx = pkt->sector;
		regs.x.bx = (__tb & 0x0F);
		regs.x.ds = (__tb >> 4) + 2;
		regs.x.ip = (__tb & 0x0F);
		regs.x.cs = (__tb >> 4) + 1;
		_go32_dpmi_simulate_fcall(&regs);

		if (!(regs.x.flags & 1))
			return DSK_ERR_OK;
/*	{
		unsigned char buf[1024];
		dosmemget(__tb, 1024, buf);
		fprintf(stderr, "smalldrive: error 0x%04x\n", regs.x.ax);
		dosmemput(buf, 1024, __tb);
	} */
/* Returns 0x207 on a >32Mb drive, 0x0001 on a FAT32 drive */
		if (regs.x.ax != 0x207 && regs.x.ax != 0x0001 && 
				regs.x.ax != 0x701F)
			return translate_error(regs.x.ax);
	}
Ejemplo n.º 6
0
void clrscr(void)
{
  short filler[txinfo.winright - txinfo.winleft + 1];
  int row, col;
  for (col=0; col < txinfo.winright - txinfo.winleft + 1; col++)
    filler[col] = ' ' | (ScreenAttrib << 8);
  for (row=txinfo.wintop-1; row < txinfo.winbottom; row++)
    dosmemput(filler, (txinfo.winright - txinfo.winleft + 1)*2,
     VIDADDR(row, txinfo.winleft - 1));
  gotoxy(1, 1);
}
Ejemplo n.º 7
0
int puttext(int c, int r, int c2, int r2, void *buf)
{
  short *cbuf = (short *)buf;
  /* we should check for valid parameters, and maybe return 0 */
  r--, r2--, c--, c2--;
  for (; r <= r2; r++)
  {
    dosmemput(cbuf, (c2-c+1)*2, VIDADDR(r, c));
    cbuf += c2-c+1;
  }
  return 1;
}
Ejemplo n.º 8
0
int set_clipboard_data(char *data, int size)
{
   __dpmi_regs r;
   int seg, sel;
   int ret = TRUE;

   if (!clipboard_version)
      return FALSE;

   r.x.ax = 0x1701;
   __dpmi_int(0x2F, &r);

   if (!r.x.ax)
      return FALSE;

   r.x.ax = 0x1702;
   __dpmi_int(0x2F, &r);

   seg = __dpmi_allocate_dos_memory((size+15)>>4, &sel);

   if (seg < 0) {
      ret = FALSE;
   }
   else {
      dosmemput(data, size, seg*16);

      r.x.ax = 0x1703;
      r.x.dx = 1;
      r.x.es = seg;
      r.x.bx = 0;
      r.x.si = size>>16;
      r.x.cx = size&0xFFFF;

      __dpmi_int(0x2F, &r);

      if (!r.x.ax)
	 ret = FALSE;

      __dpmi_free_dos_memory(sel);
   }

   r.x.ax = 0x1708;
   __dpmi_int(0x2F, &r);

   return ret;
}
Ejemplo n.º 9
0
void cd_ioctl(int drivlab, int funccode, char *addinfo)
{
  cdio.size = sizeof(cdio);     //0x10;
  cdio.subunit = 0;
  cdio.function = funccode;
  // use a 50-byte offset into transfer buffer, because sendrequest uses
  // the start of the tb
  cdio.adata = ((_use_tb / 16) << 16) & 0xffff0000;
  cdio.adata |= (_use_tb % 16);
//  printf("adata: %08X  tb: %08X\n",cdio.adata,_use_tb);
  cdio.adatasize = 20;
  dosmemput(addinfo, 20, _use_tb);
//  printf("at tb: %X %X\n",_farpeekb(_dos_ds,_use_tb),_farpeekb(_dos_ds,_use_tb+1));
  cd_sendrequest(drivlab, (CD_DEVINFO *) & cdio);
//  printf("afterat tb: %X %X\n",_farpeekb(_dos_ds,_use_tb),_farpeekb(_dos_ds,_use_tb+1));
  dosmemget(_use_tb, 20, addinfo);
//  printf("after in addinfo: %X %X\n",addinfo[0],addinfo[1]);
}
Ejemplo n.º 10
0
/* FAT32_AbsReadWrite() is modified from TE_AbsReadWrite(). */
unsigned int FAT32_AbsReadWrite(char DosDrive, int count, ULONG sector,
									ULONG buffer, unsigned int ReadOrWrite)
{
	struct DRP {
		unsigned long  sectorNumber;
		unsigned short count;
		unsigned short offset;
		unsigned short segment;	/* transfer address */
	} diskReadPacket;

	struct {
		unsigned direction  : 1 ; /* low bit */
		unsigned reserved_1 : 12;
		unsigned write_type : 2 ;
		unsigned reserved_2 : 1 ;
	} mode_flags;

	diskReadPacket.sectorNumber	= sector;
	diskReadPacket.count		= count;
	diskReadPacket.segment		= FP_SEG(buffer);
	diskReadPacket.offset		= FP_OFF(buffer);
	/* Using transfer buffer */
	dosmemput(&diskReadPacket, sizeof(struct DRP), transfer_buffer);

	mode_flags.reserved_1 = 0;
	mode_flags.write_type = 0;
	mode_flags.direction  = (ReadOrWrite == READ) ? 0 : 1;
	mode_flags.reserved_2 = 0;

	DosDrive++;

	/* no inline asm for Turbo C 2.01! -ea */
	/* Turbo C also complains about packed bitfield structures -ea */
	regs.x.ax = 0x7305;
	regs.x.ds = FP_SEG(transfer_buffer);
	regs.x.bx = FP_OFF(transfer_buffer);
	regs.x.cx = 0xffff;
	regs.h.dl = DosDrive;
	regs.x.si = mode_flags.direction; /* | (mode_flags.write_type << 13); */
	__dpmi_int(0x21, &regs);
	return ((regs.x.flags&CARRY_FLAG) ? regs.x.ax : 0);
}
Ejemplo n.º 11
0
/* install the real-mode critical error handler
 */
void hard_error_catch_setup(void)
{
    /* On first call, allocate some DOS memory and copy the handler into it
     */
    if(!handler_installed) {
        handler_installed = TRUE;
        new_handler_info.size = old_handler_info.size = 1;
        if (_go32_dpmi_allocate_dos_memory(&new_handler_info) != 0) {
            fprintf(stderr,"Couldn't allocate handler memory\n");
            exit(1);
        }
        dosmemput(handler, 16, new_handler_info.rm_segment * 16);
#ifdef XDEBUG
        sprintf(Tempbuf, "Handler at segment %x", new_handler_info.rm_segment);
        error_msg(Tempbuf, 0);
#endif
    }
    _go32_dpmi_get_real_mode_interrupt_vector(0x24, &old_handler_info);
    _go32_dpmi_set_real_mode_interrupt_vector(0x24, &new_handler_info);
    clear_hard_error();
    return;
}
Ejemplo n.º 12
0
DMP_INLINE(void) EP2_InHandler(USB_Device *usb)
{
	int len = 0;
	
	if (usb->bulk_in_transmitting == true) return;
	if (usb->xmit->count <= 0) return;
	
#ifdef DMP_86DUINO_MODE
	TX_LED_ON();
#endif	
	
	do {
		usb->EP[2].InBuf[len++] =(BYTE)PopQueue(usb->xmit);
	} while(usb->xmit->count > 0 && len < EP2_MAX_PACKET_SIZE_IN);
	
	#if defined DMP_DOS_DJGPP
	dosmemput(usb->EP[2].InBuf, EP2_MAX_PACKET_SIZE_IN, usb->EP[2].InPhysical);
	#endif
	
	SetEPnDLR(usb, EP2, IN, ENABLE | len);
	usb->bulk_in_transmitting = true;
}
Ejemplo n.º 13
0
void display_dos_titlebar(char *title)
{
    __dpmi_regs r;
    char buffer[81];

    /* INT 2F - Windows95 - TITLE - SET APPLICATION TITLE
     * AX = 168Eh
     * DX = 0000h
     * ES:DI -> ASCIZ application title (max 79 chars+NUL)
     * Return: AX = status
     * 0000h failed
     * 0001h successful
     * Note:   if ES:DI is 0000h:0000h or points at an empty string, the current
     * title is removed
     * BUG:    this function can return a successful status even though the title was
     * not changed; reportedly, waiting for two clock ticks after program
     * startup solves this problem
     */

    if (windows == 1) {
        /* Put the title in the MS-Windows window.  Max 79 chars+NULL */
        if (strlen(title) > 79) {
            strncpy(buffer, title, 79);
            buffer[79] = '\0';
        } else {
            strcpy(buffer, title);
        }
        /* Copy the title to the transfer buffer */
        dosmemput(&buffer, 80, __tb);
        r.x.ax = 0x168E;
        r.x.dx = 0x0000;
        r.x.di = __tb & 0x0f;
        r.x.es = __tb >> 4;
        __dpmi_int(0x2f, &r);
    }
    if (windows == 2) {
        /* FIXME -- Anyone know how to do this in NT? */
    }
}
Ejemplo n.º 14
0
int file_get_lfn( const char *in, char *out )
{
  char src[MAX_PATH+32]; // jtbs
  char dst[MAX_PATH+32]; // jtbs

  strcpy( src, in );

  __dpmi_regs r;
  dosmemput(src, strlen (src)+1, __tb);
  r.x.ax = 0x7160;    /* Truename */
  r.x.cx = 2;     /* Get long name */
  r.x.ds = r.x.es = __tb / 16;
  r.x.si = r.x.di = __tb & 15;
  __dpmi_int(0x21, &r);
  if (r.x.flags & 1 || r.x.ax == 0x7100)
    {
    strcpy( out, in );
    return -1;
    }
  dosmemget (__tb, MAX_PATH, dst);
  strcpy( out, dst );
  return 0;
}
Ejemplo n.º 15
0
/* Do not confuse this with DOS 7.0+ drive locking */
void Enable_Disk_Access(void) /* DOS 4.0+ drive access flag / locking */
{
	unsigned char category_code;
	unsigned long error_code=0;

	category_code = (param.fat_type == FAT32) ? 0x48 : 0x08;

	/* Get the device parameters for the logical drive */

	regs.h.ah	= 0x44;						/* IOCTL Block Device Request */
	regs.h.al	= 0x0d;						/* IOCTL */
	regs.h.bl	= param.drive_number + 1;
	regs.h.ch	= category_code;			/* 0x08 if !FAT32, 0x48 if FAT32 */
	regs.h.cl	= 0x67;						/* Get Access Flags */
	regs.x.ds	= FP_SEG(transfer_buffer);
	regs.x.dx	= FP_OFF(transfer_buffer);
	/* TODO: Using linear address because the DS's base is 0x0? */

	__dpmi_int(0x21, &regs);
	/* Copy to the access_flags from transfer buffer */
	dosmemget(transfer_buffer, sizeof(AF), &access_flags);
	access_flags.special_function = 0;
	error_code = regs.h.al;

	if (regs.x.flags&CARRY_FLAG)
	{
		/* BO: if invalid function: try to format anyway maybe access
		 flags do not work this way in this DOS (e.g. DRDOS 7.03) */
		if (error_code == 0x1 || error_code == 0x16)
		{
			printf("No disk access flags used (IOCTL int 21.440d.x8.67)\n");
			return;
		}

		/* Add error trapping here */
		printf("\nCannot get disk access flags (error %02lx). Giving up.\n", error_code);
		Exit(4,26);
	}

	if (access_flags.disk_access==0) /* access not yet enabled? */
	{
		access_flags.disk_access = 1;
		dosmemput(&access_flags, sizeof(AF), transfer_buffer);

		regs.h.ah = 0x44;                     /* IOCTL Block Device Request */
		regs.h.al = 0x0d;                     /* IOCTL */
		regs.h.bl = param.drive_number + 1;
		regs.h.ch = category_code;            /* 0x08 if !FAT32, 0x48 if FAT32 */
		regs.h.cl = 0x47;                     /* Set access flags */
		regs.x.es = FP_SEG(transfer_buffer);
		regs.x.dx = FP_OFF(transfer_buffer);
		__dpmi_int(0x21, &regs);

		error_code = regs.h.al;
		/* Copy to the access_flags from transfer buffer */
		dosmemget(transfer_buffer, sizeof(AF), &access_flags);
		
		if (regs.x.flags&CARRY_FLAG)
		{
			/* Add error trapping here */
			printf("\nCannot enable disk access flags (error %02lx). Giving up.\n", error_code);
			Exit(4,27);
		}
	}

	#ifdef __FORMAT_DEBUG__
	printf("[DEBUG]  Enabled disk access flags.\n");
	#endif
}
Ejemplo n.º 16
0
int cputs(const char *s)
{
  int     row, col,c;
  const unsigned char *ss = (const unsigned char *)s;
  short *viaddr;
  short sa = ScreenAttrib << 8;
  ScreenGetCursor(&row, &col);
  viaddr = (short *)VIDADDR(row,col);
  /*
   * Instead of just calling putch; we do everything by hand here,
   * This is much faster. We don't move the cursor after each character,
   * only after the whole string is written, because ScreenSetCursor
   * needs to long because of switching to real mode needed with djgpp.
   * You won't recognize the difference.
   */
  while ((c = *ss++))
    {
      /*  first, handle the character */
      if (c == '\n')
	{
	  row++;
	  viaddr += txinfo.screenwidth;
	}
      else if (c == '\r')
	{
	  col = txinfo.winleft - 1;
	  viaddr = (short *)VIDADDR(row,col);
	}
      else if (c == '\b')
        {
          if (col > txinfo.winleft-1)
          {
              col--;
              viaddr--;
          }
          else if (row > txinfo.wintop -1)
          {
              /*
               * Turbo-C ignores this case. We want to be able to
               * edit strings with backspace in gets after
               * a linefeed, so we are smarter
               */
              row--;
              col = txinfo.winright-1;
              viaddr = (short *)VIDADDR(row,col);
          }
        }
      else if (c == 0x07)
          bell();
      else {
        short q = c | sa;
        dosmemput(&q, 2, (int)viaddr);
	viaddr++;
	col++;
      }

      /* now, readjust the window     */

      if (col >= txinfo.winright) {
	col = txinfo.winleft - 1;
	row++;
	viaddr = (short *)VIDADDR(row,col);
      }

      if (row >= txinfo.winbottom) {
	ScreenSetCursor(txinfo.wintop-1,0); /* goto first line in window */
	delline();                          /* and delete it */
	row--;
	viaddr -= txinfo.screenwidth;
      }
    }

  ScreenSetCursor(row, col);
  txinfo.cury = row - txinfo.wintop + 2;
  txinfo.curx = col - txinfo.winleft + 2;
  return(*(--ss));
}
Ejemplo n.º 17
0
int  Driver_Display_Bitmap( char*  buffer, int  line, int  col )
{
    int    y, used_col;
    char*  target;

#ifdef DJGPP
    char cbuf = 0;
    int i;
#endif

#ifdef DJGPP_USE_NEAR_POINTERS
    if( djgpp_use_nearpointers )
        if( ! __djgpp_nearptr_enable() )
            /* doesn't work, probably under some real OS like NT or dosemu! */
            djgpp_use_nearpointers = 0;
        else
            Vio += __djgpp_conventional_base;
#endif

#ifdef DJGPP
    if( !djgpp_use_nearpointers )
        for( i = 0; i < vio_Height*vio_ScanLineWidth; i++ )
            dosmemput( &cbuf, 1, (unsigned long) Vio+i );
    else
        /*FALLTHROUGH*/
#endif
        memset( Vio, 0, vio_Height * vio_ScanLineWidth );

    if ( line > vio_Height )
        line = vio_Height;
    if ( col > vio_ScanLineWidth )
        used_col = vio_ScanLineWidth;
    else
        used_col = col;

    target = Vio + ( line - 1 ) * vio_ScanLineWidth;

    for ( y = 0; y < line; y++ )
    {
#ifdef DJGPP
        if( !djgpp_use_nearpointers )
            dosmemput( buffer, used_col, (unsigned long)target );
        else
            /*FALLTHROUGH*/
#endif
            memcpy( target, buffer, used_col );

        target -= vio_ScanLineWidth;
        buffer += col;
    }

#ifdef DJGPP_USE_NEAR_POINTERS
    if( djgpp_use_nearpointers )
    {
        Vio -= __djgpp_conventional_base;
        __djgpp_nearptr_disable();
    }
#endif

    return 1;                   /* success */
}
Ejemplo n.º 18
0
/* Copy data into the clipboard, return zero if successful.  */
unsigned
set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw)
{
  __dpmi_regs regs;
  unsigned truelen;
  unsigned long xbuf_addr, buf_offset;
  unsigned char *dp = Data, *dstart = dp;

  if (Format != CF_OEMTEXT)
    return 3;

  /* need to know final size after '\r' chars are inserted (the
     standard CF_OEMTEXT clipboard format uses CRLF line endings,
     while Emacs uses just LF internally).  */
  truelen = Size + 1;		/* +1 for the terminating null */

  if (!Raw)
    {
      /* avoid using strchr because it recomputes the length everytime */
      while ((dp = memchr (dp, '\n', Size - (dp - dstart))) != 0)
	{
	  truelen++;
	  dp++;
	}
    }

  if (clipboard_compact (truelen) < truelen)
    return 1;

  if ((xbuf_addr = alloc_xfer_buf (truelen)) == 0)
    return 1;

  /* Move the buffer into the low memory, convert LF into CR-LF if needed.  */
  if (Raw)
    {
      dosmemput (Data, Size, xbuf_addr);

      /* Terminate with a null, otherwise Windows does strange things
	 when the text size is an integral multiple of 32 bytes. */
      _farpokeb (_dos_ds, xbuf_addr + Size, '\0');
    }
  else
    {
      dp = Data;
      buf_offset = xbuf_addr;
      _farsetsel (_dos_ds);
      while (Size--)
	{
	  /* Don't allow them to put binary data into the clipboard, since
	     it will cause yanked data to be truncated at the first null.  */
	  if (*dp == '\0')
	    return 2;
	  if (*dp == '\n')
	    _farnspokeb (buf_offset++, '\r');
	  _farnspokeb (buf_offset++, *dp++);
	}

      /* Terminate with a null, otherwise Windows does strange things
	 when the text size is an integral multiple of 32 bytes. */
      _farnspokeb (buf_offset, '\0');
    }

  /* Stash away the data we are about to put into the clipboard, so we
     could later check inside get_clipboard_data whether the clipboard
     still holds our data.  */
  if (clipboard_storage_size < truelen)
    {
      clipboard_storage_size = truelen + 100;
      last_clipboard_text =
	(char *) xrealloc (last_clipboard_text, clipboard_storage_size);
    }
  if (last_clipboard_text)
    dosmemget (xbuf_addr, truelen, last_clipboard_text);

  /* Calls Int 2Fh/AX=1703h with:
	             DX = WinOldAp-Supported Clipboard format
                     ES:BX = Pointer to data
                     SI:CX = Size of data in bytes
     Return Values   AX == 0: Error occurred
			<> 0: OK.  Data copied into the Clipboard.  */
  regs.x.ax = 0x1703;
  regs.x.dx = Format;
  regs.x.si = truelen >> 16;
  regs.x.cx = truelen & 0xffff;
  regs.x.es = xbuf_addr >> 4;
  regs.x.bx = xbuf_addr & 15;
  __dpmi_int (0x2f, &regs);

  free_xfer_buf ();

  /* If the above failed, invalidate the local copy of the clipboard.  */
  if (regs.x.ax == 0)
    *last_clipboard_text = '\0';

  /* Zero means success, otherwise (1, 2, or 3) it's an error.  */
  return regs.x.ax > 0 ? 0 : 3;
}
Ejemplo n.º 19
0
Archivo: idos.c Proyecto: lavv17/inter
void  poke(unsigned short seg,unsigned short offs,short value)
{
   dosmemput(&value,2,(seg<<4)+offs);
}
Ejemplo n.º 20
0
Archivo: idos.c Proyecto: lavv17/inter
void  pokeb(unsigned short seg,unsigned short offs,char value)
{
   dosmemput(&value,1,(seg<<4)+offs);
}
Ejemplo n.º 21
0
int pkt_test_upcall (void)
{
#if !defined(NO_RMODE_CALL)
  int i, max = RX_BUFS + 3;

  for (i = 0; i < max; i++)
  {
    eth_Packet eth;
    IREGS      regs;
    DWORD      linear = 0;

    memset (&regs, 0, sizeof(regs));
    memset (&eth, 0, sizeof(eth));
    eth.head.type = IP4_TYPE;
    memset (&eth.head.destination, 0xFF, 6);
    memcpy (&eth.head.source, _eth_addr, 6);

#if (DOSX & (PHARLAP|X32VM))
    rmc.eax = 0;
    rmc.ebx = _pkt_inf->handle;
    rmc.ecx = ETH_MAX;
#endif
    regs.r_cx = ETH_MAX;
    regs.r_bx = _pkt_inf->handle;
    regs.r_ax = 0;
    regs.r_cs = _pkt_inf->rm_seg;
    regs.r_ip = PktReceiver;

    if (DPMI_REAL_CALL(&regs))
    {
      linear = SEG_OFS_ADDR (regs.r_es, regs.r_di);

      printf ("Upcall AX=0: ES:DI %04X:%04X\n",
              (WORD)regs.r_es, (WORD)regs.r_di);
#if (DOSX & DJGPP)
      if (linear)
         dosmemput (&eth, (WORD)regs.r_cx, linear);
#elif (DOSX & (DOS4GW|X32VM))
      if (linear)
         memcpy ((void*)linear, &eth, (WORD)regs.r_cx);
#elif (DOSX & (PHARLAP|POWERPAK))
      if (linear)
      {
        RP_SET (linear, regs.r_es, regs.r_di);
        WriteRealMem (linear, &eth, (WORD)regs.r_cx);
      }
#else
  #error Help me!
#endif
    }
    if (linear)
    {
      regs.r_ss = regs.r_sp = 0;
      regs.r_ax = 1;
      regs.r_cs = _pkt_inf->rm_seg;
      regs.r_ip = PktReceiver;
      regs.r_ds = regs.r_es;
      regs.r_si = regs.r_di;
      if (DPMI_REAL_CALL(&regs))
         printf ("Upcall AX=1\n");
    }
    printf ("buffers used %d, dropped %lu\n",
            pkt_buffers_used(), pkt_rx_dropped());
  }
#endif

  pkt_dump_real_mem();
  return (0);
}
Ejemplo n.º 22
0
static int setup_rmode_receiver (void)
{
  WORD rx_seg, rx_ofs;
  WORD asmpkt_size_chk;
  int  head_size = RX_ELEMENT_HEAD_SIZE;

  WATT_ASSERT (rm_base);
  WATT_ASSERT ((head_size % 4) == 0);

  rx_seg = _pkt_inf->rm_seg;
  rx_ofs = PktReceiver;

#if 0  /* test */
  printf ("PktReceiver @ %04X:%04X, ", rx_seg, PktReceiver);
  printf ("_asmpkt_inf @ %04X:%04X\n", rx_seg, (int)sizeof(real_stub_array));
#endif

  *(WORD*)&real_stub_array[asmpkt_inf+0] = sizeof(real_stub_array);
  *(WORD*)&real_stub_array[asmpkt_inf+2] = rx_seg;

  asmpkt_size_chk = *(WORD*) (real_stub_array + size_chk);
  if (asmpkt_size_chk != sizeof(PKT_INFO))
  {
    TCP_CONSOLE_MSG (0, ("%s (%u): Development error:\n"
                     "  sizeof(pkt_info) = %ld in pcpkt.h\n"
                     "  sizeof(pkt_info) = %u in asmpkt.nas, (diff %ld)\n",
                     __FILE__, __LINE__,
                     (long)sizeof(PKT_INFO), asmpkt_size_chk,
                     (long)(sizeof(PKT_INFO) - asmpkt_size_chk)));
    return (-1);
  }

  if (*(WORD*)&real_stub_array[PktReceiver]   != 0xA80F ||  /* push gs */
      *(WORD*)&real_stub_array[PktReceiver+2] != 0xA00F)    /* push fs */
  {
    TCP_CONSOLE_MSG (0, ("%s (%u): Development error:\n"
                         "  PktReceiver misaligned\n", __FILE__, __LINE__));
    return (-1);
  }

  if (!has_rdtsc || !use_rdtsc)
  {
    DWORD patch_it = (*(WORD*) &real_stub_array[patch_nop]) +
                     (DWORD) &real_stub_array;

    TCP_CONSOLE_MSG (4, ("patch_it (%04X): %02X,%02X,%02X\n",
                     *(WORD*)&real_stub_array[patch_nop],
                     ((BYTE*)patch_it)[0],
                     ((BYTE*)patch_it)[1],
                     ((BYTE*)patch_it)[2]));

    ((BYTE*)patch_it) [0] = 0x90;  /* NOP */
    ((BYTE*)patch_it) [1] = 0x90;
    ((BYTE*)patch_it) [2] = 0x90;
  }

#if (DOSX & (PHARLAP|POWERPAK|X32VM))
  WriteRealMem (rm_base, &real_stub_array, sizeof(real_stub_array));
#elif (DOSX & DJGPP)
  dosmemput (&real_stub_array, sizeof(real_stub_array), rm_base);
#elif (DOSX & DOS4GW) || (DOSX == 0)
  memcpy ((void*)rm_base, &real_stub_array, sizeof(real_stub_array));
#else
  #error Help me!
#endif
  return (0);
}
Ejemplo n.º 23
0
void SetupVgaEnvironment()
{
        int a, i;
        union REGS rg;
        __dpmi_regs d_rg;
        UBYTE ctab[768];

        if (use_vesa)
        {
          /*try to open VESA mode*/
          use_vesa=VESA_open(vesa_mode,vesa_memptr,vesa_memsize,&vesa_linear,&vesa_selector);
        }
        if (!use_vesa) /*if '-novesa' specified or VESA_open failed */
          switch(video_mode)
          {
            case 0:
              rg.x.ax = 0x0013;
              int86(0x10, &rg, &rg); /*vga 320x200*/
              break;
            case 1:
              x_open(2);             /*xmode 320x240*/
              break;
            case 2:
            case 3:
              x_open(5);             /*xmode 320x480*/
              break;
          }

	screen_visible_x1 = first_col;
	screen_visible_x2 = first_col + 320;
	if (video_mode == 0) {
		screen_visible_y1 = first_lno;
		screen_visible_y2 = first_lno + 200;
	}
	else {
		screen_visible_y1 = 0;
		screen_visible_y2 = 240;
	}

        vga_started = 1;

        /* setting all palette at once is faster....*/
        for (a = 0, i = 0; a < 256; a++) {
          ctab[i++]=(colortable[a] >> 18) & 0x3f;
          ctab[i++]=(colortable[a] >> 10) & 0x3f;
          ctab[i++]=(colortable[a] >> 2) & 0x3f;
        }
        /*copy ctab to djgpp transfer buffer in DOS memory*/
        dosmemput(ctab,768,__tb&0xfffff);
        d_rg.x.ax=0x1012;
        d_rg.x.bx=0;
        d_rg.x.cx=256;
        d_rg.x.dx=__tb&0xf; /*offset of transfer buffer*/
        d_rg.x.es=(__tb >> 4) & 0xffff;  /*segment of transfer buffer*/
        __dpmi_int(0x10,&d_rg);  /*VGA set palette block*/

	/* initialize mouse */
	if (mouse_mode != MOUSE_OFF) {
		union REGS rg;
		rg.x.ax = 0;
		int86(0x33, &rg, &rg);
		if (rg.x.ax != 0xffff) {
			Aprint("Can't find mouse!");
			mouse_mode = MOUSE_OFF;
		}
	}

        key_init(); /*initialize keyboard handler*/
}