Example #1
0
void runsyslinuxcmd(const char *cmd)
{
    strcpy(__com32.cs_bounce, cmd);
    REG_AX(inreg) = 0x0003;	// Run command
    REG_BX(inreg) = OFFS(__com32.cs_bounce);
    REG_ES(inreg) = SEG(__com32.cs_bounce);
    __intcall(0x22, &inreg, &outreg);
}
Example #2
0
/**********************************************************************************
函数功能:点亮或者熄灭某一个显示标志
入口:    Flag----1:显示;0:熄灭
出口:    1---------有此设备;0------找不到设备
**********************************************************************************/
INT8U SetOrClrPixPiyDot(INT16U ShouID,INT8U ClrOrSet,INT8U Type)
{
  INT16U Pos,Seg,Com;
  INT8U Flag,i,temp;
  
  Pos=GetPixySegPos_SxNxDx(ShouID,Type);
  if(!Pos)
    return 0;
  
  switch(Type)
  {
    case Sx:
       Seg=SEG(LCD_S_Const[Pos].x);
       Com=COM(LCD_S_Const[Pos].y);
       Flag=SetOrClrAndChkSEGCOM(Seg,Com,Type,ClrOrSet);
       return Flag;
  
    case Dx:
       Seg=SEG(LCD_D_Const[Pos].x);
       Com=COM(LCD_D_Const[Pos].y);
       Flag=SetOrClrAndChkSEGCOM(Seg,Com,Type,ClrOrSet);
       return Flag;

  case Nx: 
//#ifdef CONFLICT_TAB_CHKEN
//	temp=7;
//#else
	temp=1;
//#endif
      for(i=0;i<temp;i++)
      { 
        Seg=SEG(LCD_N_Const[Pos+i].x);
        Com=COM(LCD_N_Const[Pos+i].y);
      	Flag=SetOrClrAndChkSEGCOM(Seg,Com,Type,ClrOrSet);
      	if(!Flag)
      	return 0;
      }
      return 1;

			
      
	}

  return 0;
}
void EC_CONVERGING::Apply( EDIT_LINE& aHandle )
{
    // The dragged segment endpoints
    EDIT_POINT& origin = aHandle.GetOrigin();
    EDIT_POINT& end = aHandle.GetEnd();

    if( m_colinearConstraint )
    {
        m_colinearConstraint->Apply( origin );
        m_colinearConstraint->Apply( end );
    }

    // The dragged segment
    SEG dragged( origin.GetPosition(), origin.GetPosition() + m_draggedVector );

    // Do not allow points on the adjacent segments move freely
    m_originSideConstraint->Apply();
    m_endSideConstraint->Apply();

    EDIT_POINT& prevOrigin = *m_editPoints.Previous( origin, false );
    EDIT_POINT& nextEnd = *m_editPoints.Next( end, false );

    // Two segments adjacent to the dragged segment
    SEG originSide = SEG( origin.GetPosition(), prevOrigin.GetPosition() );
    SEG endSide = SEG( end.GetPosition(), nextEnd.GetPosition() );

    // First intersection point (dragged segment against origin side)
    if( OPT_VECTOR2I originIntersect = dragged.IntersectLines( originSide ) )
        origin.SetPosition( *originIntersect );

    // Second intersection point (dragged segment against end side)
    if( OPT_VECTOR2I endIntersect = dragged.IntersectLines( endSide ) )
        end.SetPosition( *endIntersect );

    // Check if adjacent segments intersect (did we dragged the line to the point that it may
    // create a selfintersecting polygon?)
    originSide = SEG( origin.GetPosition(), prevOrigin.GetPosition() );
    endSide = SEG( end.GetPosition(), nextEnd.GetPosition() );

    if( OPT_VECTOR2I originEndIntersect = endSide.Intersect( originSide ) )
    {
        origin.SetPosition( *originEndIntersect );
        end.SetPosition( *originEndIntersect );
    }
}
Example #4
0
int getVBEInfo( void *infoBlock )
{
    bb.intno  = 0x10;
    bb.eax.rr = funcGetControllerInfo;
    bb.es     = SEG( infoBlock );
    bb.edi.rr = OFF( infoBlock );
    bios( &bb );
    return(bb.eax.r.h);
}
Example #5
0
const SHAPE_LINE_CHAIN ConvexHull( const SHAPE_CONVEX& aConvex, int aClearance )
{
    // this defines the horizontal and vertical lines in the hull octagon
    BOX2I box = aConvex.BBox( aClearance + HULL_MARGIN );
    box.Normalize();

    SEG topline = SEG( VECTOR2I( box.GetX(), box.GetY() + box.GetHeight() ),
                       VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() + box.GetHeight() ) );
    SEG rightline = SEG( VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() + box.GetHeight() ),
                         VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() ) );
    SEG bottomline = SEG( VECTOR2I( box.GetX() + box.GetWidth(), box.GetY() ),
             box.GetOrigin() );
    SEG leftline = SEG( box.GetOrigin(), VECTOR2I( box.GetX(), box.GetY() + box.GetHeight() ) );

    const SHAPE_LINE_CHAIN& vertices = aConvex.Vertices();

    // top right diagonal
    VECTOR2I corner = box.GetOrigin() + box.GetSize();
    SEG toprightline = SEG( corner,
                            corner + VECTOR2I( box.GetHeight(), -box.GetHeight() ) );
    MoveDiagonal( toprightline, vertices, aClearance );

    // bottom right diagonal
    corner = box.GetOrigin() + VECTOR2I( box.GetWidth(), 0 );
    SEG bottomrightline = SEG( corner + VECTOR2I( box.GetHeight(), box.GetHeight() ),
                               corner );
    MoveDiagonal( bottomrightline, vertices, aClearance );

    // bottom left diagonal
    corner = box.GetOrigin();
    SEG bottomleftline = SEG( corner,
                              corner + VECTOR2I( -box.GetHeight(), box.GetHeight() ) );
    MoveDiagonal( bottomleftline, vertices, aClearance );

    // top left diagonal
    corner = box.GetOrigin() + VECTOR2I( 0, box.GetHeight() );
    SEG topleftline = SEG( corner + VECTOR2I( -box.GetHeight(), -box.GetHeight() ),
                           corner );
    MoveDiagonal( topleftline, vertices, aClearance );

    SHAPE_LINE_CHAIN octagon;
    octagon.SetClosed( true );

    octagon.Append( *leftline.IntersectLines( bottomleftline ) );
    octagon.Append( *bottomline.IntersectLines( bottomleftline ) );
    octagon.Append( *bottomline.IntersectLines( bottomrightline ) );
    octagon.Append( *rightline.IntersectLines( bottomrightline ) );
    octagon.Append( *rightline.IntersectLines( toprightline ) );
    octagon.Append( *topline.IntersectLines( toprightline ) );
    octagon.Append( *topline.IntersectLines( topleftline ) );
    octagon.Append( *leftline.IntersectLines( topleftline ) );

    return octagon;
}
Example #6
0
static int pxeapi_call(int func, const uint8_t *buf)
{
	static com32sys_t inargs, outargs;
	inargs.eax.w[0] = 0x0009; /* Call PXE Stack */
	inargs.ebx.w[0] = func; /* PXE function number */
	inargs.edi.w[0] = OFFS(buf);
	inargs.es = SEG(buf);
	__intcall(0x22, &inargs, &outargs);
	return outargs.eax.w[0] == PXENV_EXIT_SUCCESS;
}
Example #7
0
PNS_ITEM* PNS_ROUTER::syncTrack( TRACK* aTrack )
{
    PNS_SEGMENT* s =
        new PNS_SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() );

    s->SetWidth( aTrack->GetWidth() );
    s->SetLayers( PNS_LAYERSET( aTrack->GetLayer() ) );
    s->SetParent( aTrack );
    return s;
}
Example #8
0
int getVBEModeInfo( int mode, void *minfo_p )
{
    bb.intno  = 0x10;
    bb.eax.rr = funcGetModeInfo;
    bb.ecx.rr = mode;
    bb.es     = SEG(minfo_p);
    bb.edi.rr = OFF(minfo_p);
    bios(&bb);
    return(bb.eax.r.h);
}
Example #9
0
static void dump_e820(void)
{
    com32sys_t ireg, oreg;
    struct e820_data ed;
    uint32_t type;
    void *low_ed;

    low_ed = lmalloc(sizeof ed);
    if (!low_ed)
        return;

    memset(&ireg, 0, sizeof ireg);

    ireg.eax.w[0] = 0xe820;
    ireg.edx.l = 0x534d4150;
    ireg.ecx.l = sizeof(struct e820_data);
    ireg.edi.w[0] = OFFS(low_ed);
    ireg.es = SEG(low_ed);

    memset(&ed, 0, sizeof ed);
    ed.extattr = 1;

    do {
        memcpy(low_ed, &ed, sizeof ed);

        __intcall(0x15, &ireg, &oreg);
        if (oreg.eflags.l & EFLAGS_CF ||
                oreg.eax.l != 0x534d4150 || oreg.ecx.l < 20)
            break;

        memcpy(&ed, low_ed, sizeof ed);

        if (oreg.ecx.l >= 24) {
            /* ebx base length end type */
            printf("%8x %016llx %016llx %016llx %d [%x]",
                   ireg.ebx.l, ed.base, ed.len, ed.base + ed.len, ed.type,
                   ed.extattr);
        } else {
            /* ebx base length end */
            printf("%8x %016llx %016llx %016llx %d [-]",
                   ireg.ebx.l, ed.base, ed.len, ed.base + ed.len, ed.type);
            ed.extattr = 1;
        }

        type = ed.type - 1;
        if (type < sizeof(e820_types) / sizeof(e820_types[0]))
            printf(" %s", e820_types[type]);

        putchar('\n');

        ireg.ebx.l = oreg.ebx.l;
    } while (ireg.ebx.l);

    lfree(low_ed);
}
Example #10
0
int setVBEMode(unsigned short mode, const VBECRTCInfoBlock * timing)
{
    bb.intno  = 0x10;
    bb.eax.rr = funcSetMode;
    bb.ebx.rr = mode;
    if (timing) {
        bb.es     = SEG(timing);
        bb.edi.rr = OFF(timing);
    }
    bios(&bb);
    return(bb.eax.r.h);
}
Example #11
0
int getVBEPalette(void *palette)
{
	bb.intno = 0x10;
	bb.eax.rr = funcGetSetPaletteData;
	bb.ebx.r.l = subfuncGet;
	bb.ecx.rr = 256;
	bb.edx.rr = 0;
	bb.es = SEG(palette);
	bb.edi.rr = OFF(palette);
	bios(&bb);
	return(bb.eax.r.h);
}
Example #12
0
int getEDID(void * edidBlock, UInt8 block)
{
    bzero(&bb, sizeof(bb));
    bb.intno  = 0x10;
    bb.eax.rr = funcGetEDID;
    bb.ebx.r.l= 0x01;
    bb.edx.rr = block;
    bb.es     = SEG(edidBlock);
    bb.edi.rr = OFF(edidBlock);
    bios(&bb);
    return(bb.eax.r.h);
}
Example #13
0
/*
 * Boot a specified local disk.  AX specifies the BIOS disk number; or
 * -1 in case we should execute INT 18h ("next device.")
 */
__export void local_boot(int16_t ax)
{
	com32sys_t ireg, oreg;
	int i;

        memset(&ireg, 0, sizeof(ireg));
	syslinux_force_text_mode();

	writestr(LOCALBOOT_MSG);
	crlf();
	cleanup_hardware();

	if (ax == -1) {
		/* Hope this does the right thing */
		__intcall(0x18, &zero_regs, NULL);

		/* If we returned, oh boy... */
		kaboom();
	}

	/*
	 * Load boot sector from the specified BIOS device and jump to
	 * it.
	 */
	memset(&ireg, 0, sizeof ireg);
	ireg.edx.b[0] = ax & 0xff;
	ireg.eax.w[0] = 0;	/* Reset drive */
	__intcall(0x13, &ireg, NULL);

	memset(&ireg, 0, sizeof(ireg));
	ireg.eax.w[0] = 0x0201;	/* Read one sector */
	ireg.ecx.w[0] = 0x0001;	/* C/H/S = 0/0/1 (first sector) */
	ireg.ebx.w[0] = OFFS(trackbuf);
	ireg.es = SEG(trackbuf);

	for (i = 0; i < retry_count; i++) {
		__intcall(0x13, &ireg, &oreg);

		if (!(oreg.eflags.l & EFLAGS_CF))
			break;
	}

	if (i == retry_count)
		kaboom();

	cli();			/* Abandon hope, ye who enter here */
	memcpy((void *)0x07C00, trackbuf, 512);

	ireg.esi.w[0] = OFFS(trackbuf);
	ireg.edi.w[0] = 0x07C00;
	ireg.edx.w[0] = ax;
	call16(local_boot16, &ireg, NULL);
}
Example #14
0
    void AddDirections( VECTOR2D aP, int aMask, int aColor )
    {
        BOX2I b( aP - VECTOR2I( 10000, 10000 ), VECTOR2I( 20000, 20000 ) );

        AddBox( b, aColor );
        for( int i = 0; i < 8; i++ )
        {
            if( ( 1 << i ) & aMask )
            {
                VECTOR2I v = DIRECTION_45( ( DIRECTION_45::Directions ) i ).ToVector() * 100000;
                AddSegment( SEG( aP, aP + v ), aColor );
            }
        }
    }
Example #15
0
// Set up CPU's kernel segment descriptors.
// Run once on entry on each CPU.
void seginit(void) {
	struct cpu *c;

	// Map "logical" addresses to virtual addresses using identity map.
	// Cannot share a CODE descriptor for both kernel and user
	// because it would have to have DPL_USR, but the CPU forbids
	// an interrupt from CPL=0 to DPL=3.
	c = &cpus[cpunum()];
	c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0);
	c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
	c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER);
	c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER);

	// Map cpu, and curproc
	c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0);

	lgdt(c->gdt, sizeof(c->gdt));
	loadgs(SEG_KCPU << 3);

	// Initialize cpu-local storage.
	cpu = c;
	proc = 0;
}
Example #16
0
std::unique_ptr<PNS::SEGMENT> PNS_KICAD_IFACE::syncTrack( TRACK* aTrack )
{
    std::unique_ptr< PNS::SEGMENT > segment(
        new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
    );

    segment->SetWidth( aTrack->GetWidth() );
    segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
    segment->SetParent( aTrack );

    if( aTrack->IsLocked() )
        segment->Mark( PNS::MK_LOCKED );

    return segment;
}
Example #17
0
static void
segmentremove(Chan *c)
{
	Globalseg *g;
	int x;

	if(TYPE(c) != Qsegdir)
		error(Eperm);
	lock(&globalseglock);
	x = SEG(c);
	g = globalseg[x];
	globalseg[x] = nil;
	unlock(&globalseglock);
	if(g != nil)
		putgseg(g);
}
Example #18
0
bool is_gpxe(void)
{
    const struct syslinux_version *sv;
    com32sys_t reg;
    struct s_PXENV_FILE_CHECK_API *fca;
    bool gpxe;

    sv = syslinux_version();
    if (sv->filesystem != SYSLINUX_FS_PXELINUX)
        return false;           /* Not PXELINUX */

    fca = lzalloc(sizeof *fca);
    if (!fca)
	return false;
    fca->Size = sizeof *fca;
    fca->Magic = 0x91d447b2;

    memset(&reg, 0, sizeof reg);
    reg.eax.w[0] = 0x0009;
    reg.ebx.w[0] = 0x00e6;      /* PXENV_FILE_API_CHECK */
    /* reg.edi.w[0] = OFFS(fca); */
    reg.es = SEG(fca);

    __intcall(0x22, &reg, &reg);

    gpxe = true;

    if (reg.eflags.l & EFLAGS_CF)
	gpxe = false;           /* Cannot invoke PXE stack */

    if (reg.eax.w[0] || fca->Status)
        gpxe = false;           /* PXE failure */

    if (fca->Magic != 0xe9c17b20)
        gpxe = false;           /* Incorrect magic */

    if (fca->Size < sizeof *fca)
        gpxe = false;           /* Short return */

    /* XXX: The APIs to test for should be a passed-in option */
    if (!(fca->APIMask & (1 << 5)))
	gpxe = false;           /* No FILE EXEC */

    lfree(fca);
    return gpxe;
}
Example #19
0
void OS::udp_write(const void *buf, const size_t len, uint32_t to_ip)
{
	t_PXENV_UDP_WRITE *pxe_write_param = (t_PXENV_UDP_WRITE *)lzalloc(sizeof(t_PXENV_UDP_WRITE) + len);
	xassert(pxe_write_param);
	char *buf_reloc = (char *)pxe_write_param + sizeof(*pxe_write_param);

	pxe_write_param->ip = to_ip;
	pxe_write_param->src_port = htons(UDP_PORT_NO);
	pxe_write_param->dst_port = htons(UDP_PORT_NO);
	pxe_write_param->buffer.seg = SEG(buf_reloc);
	pxe_write_param->buffer.offs = OFFS(buf_reloc);
	pxe_write_param->buffer_size = len;

	memcpy(buf_reloc, buf, len);
	pxeapi_call(PXENV_UDP_WRITE, (uint8_t *)pxe_write_param);
	lfree(pxe_write_param);
}
Example #20
0
/*
 *  returns with globalseg incref'd
 */
static Globalseg*
getgseg(Chan *c)
{
	int x;
	Globalseg *g;

	x = SEG(c);
	lock(&globalseglock);
	if(x >= nelem(globalseg))
		panic("getgseg");
	g = globalseg[x];
	if(g != nil)
		incref(g);
	unlock(&globalseglock);
	if(g == nil)
		error("global segment disappeared");
	return g;
}
Example #21
0
static void dump_e820(void)
{
  com32sys_t ireg, oreg;
  struct e820_data ed;
  uint32_t type;

  memset(&ireg, 0, sizeof ireg);

  ireg.eax.w[0] = 0xe820;
  ireg.edx.l    = 0x534d4150;
  ireg.ecx.l    = sizeof(struct e820_data);
  ireg.edi.w[0] = OFFS(__com32.cs_bounce);
  ireg.es       = SEG(__com32.cs_bounce);

  memset(&ed, 0, sizeof ed);
  ed.extattr = 1;

  do {
    memcpy(__com32.cs_bounce, &ed, sizeof ed);

    __intcall(0x15, &ireg, &oreg);
    if (oreg.eflags.l & EFLAGS_CF ||
	oreg.eax.l != 0x534d4150 ||
	oreg.ecx.l < 20)
      break;

    memcpy(&ed, __com32.cs_bounce, sizeof ed);

    if (oreg.ecx.l < 24)
      ed.extattr = 1;

    /* ebx base length end type */
    printf("%8x %016llx %016llx %016llx %d [%x]",
	   ireg.ebx.l, ed.base, ed.len, ed.base+ed.len, ed.type, ed.extattr);

    type = ed.type - 1;
    if (type < sizeof(e820_types)/sizeof(e820_types[0]))
      printf(" %s", e820_types[type]);

    putchar('\n');

    ireg.ebx.l = oreg.ebx.l;
  } while (ireg.ebx.l);
}
Example #22
0
bool OS::memmap_entry(uint64_t *base, uint64_t *length, uint64_t *type)
{
	state.eax.l = 0xe820;
	state.edx.l = STR_DW_N("SMAP");
	state.ecx.l = sizeof(*ent);
	state.edi.w[0] = OFFS(ent);
	state.es = SEG(ent);

	__intcall(0x15, &state, &state);
	xassert(state.eax.l == STR_DW_N("SMAP"));

	// detect if bootloader is called again
	if (!ent->length)
		fatal("Bootloader already executed; check boot configuration!");

	*base = ent->base;
	*length = ent->length;
	*type = ent->type;

	return state.ebx.l > 0;
}
Example #23
0
static bool is_gpxe(void)
{
    const struct syslinux_version *sv;
    com32sys_t reg;
    struct s_PXENV_FILE_CHECK_API *fca;

    sv = syslinux_version();
    if (sv->filesystem != SYSLINUX_FS_PXELINUX)
	return false;		/* Not PXELINUX */

    fca = __com32.cs_bounce;
    memset(fca, 0, sizeof *fca);
    fca->Size = sizeof *fca;
    fca->Magic = 0x91d447b2;

    memset(&reg, 0, sizeof reg);
    reg.eax.w[0] = 0x0009;
    reg.ebx.w[0] = 0x00e6;	/* PXENV_FILE_API_CHECK */
    reg.edi.w[0] = OFFS(fca);
    reg.es = SEG(fca);

    __intcall(0x22, &reg, &reg);

    if (reg.eflags.l & EFLAGS_CF)
	return false;		/* Cannot invoke PXE stack */

    if (reg.eax.w[0] || fca->Status)
	return false;		/* PXE failure */

    if (fca->Magic != 0xe9c17b20)
	return false;		/* Incorrect magic */

    if (fca->Size < sizeof *fca)
	return false;		/* Short return */

    if (!(fca->APIMask & (1 << 5)))
	return false;		/* No FILE EXEC */

    return true;
}
Example #24
0
/*
 * the ASM pxenv function wrapper, return 1 if error, or 0
 *
 */
__export int pxe_call(int opcode, void *data)
{
    static DECLARE_INIT_SEMAPHORE(pxe_sem, 1);
    extern void pxenv(void);
    com32sys_t regs;

    sem_down(&pxe_sem, 0);

#if 0
    dprintf("pxe_call op %04x data %p\n", opcode, data);
#endif

    memset(&regs, 0, sizeof regs);
    regs.ebx.w[0] = opcode;
    regs.es       = SEG(data);
    regs.edi.w[0] = OFFS(data);
    call16(pxenv, &regs, &regs);

    sem_up(&pxe_sem);

    return regs.eflags.l & EFLAGS_CF;  /* CF SET if fail */
}
Example #25
0
MSG MenuProc( HWND HWnd, MSG Msg, MPARAM MP1, MPARAM MP2 )
    {
    static struct MenuPoint MenuPoints[NUMMENUPOINTS] =
	{ { DOT,  0, "Einstellungen", EinstellungenProc, NULL },
	  { 0,	  0, "", NULL, NULL },
	  { 0,	  0, "", NULL, NULL },
	  { 0,	  0, "Durchschnitt", DurchschnittProc, NULL },
	  { 0,	  0, "������������", NULL, NULL },
	  { DOT,  1, "Periode", PeriodeProc, NULL },
	  { DOT,  1, "Abteilungen", AbteilungenProc, NULL },
	  { DOT,  1, "Begr�ndungen", BegruendungenProc, NULL },
	  { 0,	  0, "", NULL, NULL },

	  { 0,	  0, "�bersicht", UebersichtProc, NULL },
	  { 0,	  0, "���������", NULL, NULL },
	  { DOT,  1, "Periode", PeriodeProc, NULL },
	  { DOT,  1, "Person(en)", PersonenProc, NULL },
	  { DOT,  1, "Begr�ndungen", BegruendungenProc, NULL },
	  { 0,	  0, "", NULL, NULL },

	  { 0,	  0, "Grenzwerte �berschritten", UeberzeitProc, NULL },
	  { 0,	  0, "������������������������", NULL, NULL },
	  { DOT,  1, "Periode", PeriodeProc, NULL },
	  { DOT,  1, "Abteilungen", AbteilungenProc, NULL },
	  { DOT,  1, "Begr�ndungen", PMBegruendungenProc, NULL },
	  { 0,	  0, "", NULL, NULL },

	  { 0,	  0, "Summierung Zeitkonti", ZeitKontiSumProc, NULL },
	  { 0,	  0, "��������������������", NULL, NULL },
	  { DOT,  1, "Periode", PeriodeProc, NULL },
	  { DOT,  1, "Zeitkonti", ZeitKontiProc, NULL } };

    static struct HelpKey HelpKeys[NUMMENUHELPKEYS] =
	{ {  0,  0, "</>    Men�punkt anw�hlen" },
	  {  0,  1, "<Enter>  Men�punkt ausf�hren" },
	  { 40,  1, "<Esc>    Programm verlassen" } };

    static BYTE Selection;
    static BYTE TopLine;

    static BOOL PanelFocus;

    switch( Msg )
	{
	case WM_CREATE:
	    {

	    MenuPoints[5].Data = &ConfigData->Perioden[0];
	    MenuPoints[11].Data = &ConfigData->Perioden[1];
	    MenuPoints[17].Data = &ConfigData->Perioden[2];
	    MenuPoints[23].Data = &ConfigData->Perioden[3];

	    MenuPoints[6].Data = (VOID FAR *)0;
	    MenuPoints[12].Data = (VOID FAR *)1;
	    MenuPoints[18].Data = (VOID FAR *)2;

	    MenuPoints[7].Data = (VOID FAR *)0;
	    MenuPoints[13].Data = (VOID FAR *)1;
	    MenuPoints[19].Data = (VOID FAR *)2;

	    MenuPoints[24].Data = (VOID FAR *)3;
	    WinCreateWindow( HWnd, &MenuArrows, MenuArrowsProc, 0, 0, 25, -1, 25, 20 );
	    Selection = 0;
	    TopLine = 0;
	    PanelFocus = FALSE;
	    return( WM_PROCESSED );
	    }

	case WM_SHOW:
	    {
	    BYTE LineCounter;

	    WinColor( HWnd, MENU, 0, 0, WinGetx2( HWnd ), WinGety2( HWnd ) );
	    WinFill( HWnd, SPACECHAR, 0, 0, WinGetx2( HWnd ), WinGety2( HWnd ) );

	    for( LineCounter = 0; LineCounter <= WinGety2( HWnd ); LineCounter++ )
		{
		if( LineCounter + TopLine == NUMMENUPOINTS )
		    break;

		if( MenuPoints[LineCounter + TopLine].Style & DOT )
		    {
		    WinString( HWnd, "� ", LEFT, (BYTE)(MenuPoints[LineCounter + TopLine].Indent + 1), LineCounter );
		    WinString( HWnd, MenuPoints[LineCounter + TopLine].Text, LEFT, (BYTE)(MenuPoints[LineCounter + TopLine].Indent + 3), LineCounter );
		    }
		else
		    WinString( HWnd, MenuPoints[LineCounter + TopLine].Text, LEFT, (BYTE)(MenuPoints[LineCounter + TopLine].Indent + 1), LineCounter );
		}

	    return( WM_PROCESSED );
	    }

	case WM_SETFOCUS:
	    {
	    BYTE Length;

	    WinSendMsg( MenuArrows, WM_SET, (TopLine == 0 ? FALSE : TRUE ),
					    ((BYTE)(NUMMENUPOINTS - 1 - TopLine) <= WinGety2( HWnd ) ? FALSE : TRUE ) );

	    WinSendMsg( MenuArrows, WM_SHOW, 0, 0 );

	    Length = (BYTE)strlen( MenuPoints[Selection].Text );
	    if( MenuPoints[Selection].Style & DOT )
		Length += 2;

	    WinColor( HWnd, HIGHLIGHT, (BYTE)(MenuPoints[Selection].Indent), (BYTE)(Selection - TopLine), (BYTE)(MenuPoints[Selection].Indent + Length + 1), (BYTE)(Selection - TopLine) );

	    WinSendMsg( Bottomline, WM_HELP, (WORD)&HelpKeys, NUMMENUHELPKEYS );

	    WinCreateWindow( HWnd, &Panel, MenuPoints[Selection].Proc, SEG(MenuPoints[Selection].Data), OFS(MenuPoints[Selection].Data), PANELX1, PANELY1, PANELX2, PANELY2 );
	    WinSendMsg( Panel, WM_SHOW, 0, 0 );
	    return( WM_PROCESSED );
	    }

	case WM_CLEARFOCUS:
	    WinDestroyWindow( Panel );
	    WinColor( HWnd, MENU, 0, 0, WinGetx2( HWnd ), WinGety2( HWnd ) );
	    return( WM_PROCESSED );

	case WM_CHAR:
	    if( PanelFocus )
		if( WinSendMsg( Panel, Msg, MP1, MP2 ) == WM_PROCESSED )
		    return( WM_PROCESSED );

	    switch( (WORD)MP1 )
		{
		case KBDOWN:
		case KBRIGHT:
		case KBTAB:
		    WinSendMsg( HWnd, WM_CLEARFOCUS, 0, 0 );
		    do
			{
			if( Selection == NUMMENUPOINTS - 1)
			    break;

			Selection++;

			if( Selection - TopLine > WinGety2( HWnd ) )
			    {
			    TopLine++;
			    WinSendMsg( HWnd, WM_SHOW, 0, 0 );
			    }
			}
		    while( MenuPoints[Selection].Proc == NULL );

		    WinSendMsg( HWnd, WM_SETFOCUS, 0, 0 );
		    break;

		case KBUP:
		case KBLEFT:
		case KBSHTAB:
		    WinSendMsg( HWnd, WM_CLEARFOCUS, 0, 0 );
		    do
			{
			if( Selection == 0)
			    break;

			Selection--;

			if( Selection < TopLine )
			    {
			    TopLine--;
			    WinSendMsg( HWnd, WM_SHOW, 0, 0 );
			    }
			}
		    while( MenuPoints[Selection].Proc == NULL );

		    WinSendMsg( HWnd, WM_SETFOCUS, 0, 0 );
		    break;

		case KBHOME:
		    WinSendMsg( HWnd, WM_CLEARFOCUS, 0, 0 );

		    TopLine = 0;
		    Selection = 0;

		    WinSendMsg( HWnd, WM_SHOW, 0, 0 );
		    WinSendMsg( HWnd, WM_SETFOCUS, 0, 0 );
		    break;

		case KBEND:
		    WinSendMsg( HWnd, WM_CLEARFOCUS, 0, 0 );

		    Selection = NUMMENUPOINTS - 1;
		    if( NUMMENUPOINTS - 1 < WinGety2( HWnd ) )
			TopLine = 0;
		    else
			TopLine = (BYTE)(NUMMENUPOINTS - 1 - WinGety2( HWnd ));

		    WinSendMsg( HWnd, WM_SHOW, 0, 0 );
		    WinSendMsg( HWnd, WM_SETFOCUS, 0, 0 );
		    break;

		case KBENTER:
		    if( !PanelFocus )
			{
			WinSendMsg( Panel, WM_SETFOCUS, 0, 0 );
			PanelFocus = TRUE;
			return( WM_PROCESSED );
			}
		    else
			WinSendMsg( HWnd, WM_CHAR, (MPARAM)KBESC, 0 );


		case KBESC:
		    if( PanelFocus )
			{
			WinSendMsg( Panel, WM_CLEARFOCUS, 0, 0 );
			PanelFocus = FALSE;
			WinSendMsg( HWnd, WM_SETFOCUS, 0, 0 );
			return( WM_PROCESSED );
			}

		default:
		    return( MP1 );
		}
	    return( WM_PROCESSED );

	case WM_DESTROY:
	    WinDestroyWindow( MenuArrows );
	    return( WM_PROCESSED );

	}

    return( WinDefWindowProc( HWnd, Msg, MP1, MP2 ) );
    }
Example #26
0
/**
 * read_sectors - read several sectors from disk
 * @drive_info:		driveinfo struct describing the disk
 * @data:		Pre-allocated buffer for output
 * @lba:		Position to read
 * @sectors:		Number of sectors to read
 *
 * Return the number of sectors read on success or -1 on failure.
 * errno_disk contains the error number.
 **/
int read_sectors(struct driveinfo *drive_info, void *data,
		 const unsigned int lba, const int sectors)
{
    com32sys_t inreg, outreg;
    struct ebios_dapa *dapa = __com32.cs_bounce;
    void *buf = (char *)__com32.cs_bounce + sectors * SECTOR;
    char *bufp = data;

    if (get_drive_parameters(drive_info) == -1)
	return -1;

    memset(&inreg, 0, sizeof inreg);

    if (drive_info->ebios) {
	dapa->len = sizeof(*dapa);
	dapa->count = sectors;
	dapa->off = OFFS(buf);
	dapa->seg = SEG(buf);
	dapa->lba = lba;

	inreg.esi.w[0] = OFFS(dapa);
	inreg.ds = SEG(dapa);
	inreg.edx.b[0] = drive_info->disk;
	inreg.eax.b[1] = 0x42;	/* Extended read */
    } else {
	unsigned int c, h, s;

	if (!drive_info->cbios) {	// XXX errno
	    /* We failed to get the geometry */
	    if (lba)
		return -1;	/* Can only read MBR */

	    s = 1;
	    h = 0;
	    c = 0;
	} else
	    lba_to_chs(drive_info, lba, &s, &h, &c);

	// XXX errno
	if (s > 63 || h > 256 || c > 1023)
	    return -1;

	inreg.eax.w[0] = 0x0201;	/* Read one sector */
	inreg.ecx.b[1] = c & 0xff;
	inreg.ecx.b[0] = s + (c >> 6);
	inreg.edx.b[1] = h;
	inreg.edx.b[0] = drive_info->disk;
	inreg.ebx.w[0] = OFFS(buf);
	inreg.es = SEG(buf);
    }

    /* Perform the read */
    if (int13_retry(&inreg, &outreg)) {
	errno_disk = outreg.eax.b[1];
	return -1;		/* Give up */
    }

    memcpy(bufp, buf, sectors * SECTOR);

    return sectors;
}
Example #27
0
static int
segmentgen(Chan *c, char*, Dirtab*, int, int s, Dir *dp)
{
	Qid q;
	Globalseg *g;
	ulong size;

	switch(TYPE(c)) {
	case Qtopdir:
		if(s == DEVDOTDOT){
			q.vers = 0;
			q.path = PATH(0, Qtopdir);
			q.type = QTDIR;
			devdir(c, q, "#g", 0, eve, DMDIR|0777, dp);
			break;
		}

		if(s >= nelem(globalseg))
			return -1;

		lock(&globalseglock);
		g = globalseg[s];
		if(g == nil){
			unlock(&globalseglock);
			return 0;
		}
		q.vers = 0;
		q.path = PATH(s, Qsegdir);
		q.type = QTDIR;
		devdir(c, q, g->name, 0, g->uid, DMDIR|0777, dp);
		unlock(&globalseglock);

		break;
	case Qsegdir:
		if(s == DEVDOTDOT){
			q.vers = 0;
			q.path = PATH(0, Qtopdir);
			q.type = QTDIR;
			devdir(c, q, "#g", 0, eve, DMDIR|0777, dp);
			break;
		}
		/* fall through */
	case Qctl:
	case Qdata:
	case Qfree:
		g = getgseg(c);
		if(waserror()){
			putgseg(g);
			nexterror();
		}
		q.vers = 0;
		q.type = QTFILE;
		switch(s){
		case 0:
			q.path = PATH(SEG(c), Qctl);
			devdir(c, q, "ctl", 0, g->uid, g->perm, dp);
			break;
		case 1:
			q.path = PATH(SEG(c), Qdata);
			if(g->s != nil)
				size = g->s->top - g->s->base;
			else
				size = 0;
			devdir(c, q, "data", size, g->uid, g->perm, dp);
			break;
		case 2:
			q.path = PATH(SEG(c), Qfree);
			devdir(c, q, "free", 0, g->uid, g->perm&0444, dp);
			break;

		default:
			poperror();
			putgseg(g);
			return -1;
		}
		poperror();
		putgseg(g);
		break;
	}
	return 1;
}
Example #28
0
/**
 * write_sectors - write several sectors from disk
 * @drive_info:		driveinfo struct describing the disk
 * @lba:		Position to write
 * @data:		Buffer to write
 * @size:		Size of the buffer (number of sectors)
 *
 * Return the number of sectors write on success or -1 on failure.
 * errno_disk contains the error number.
 **/
int write_sectors(const struct driveinfo *drive_info, const unsigned int lba,
		  const void *data, const int size)
{
    com32sys_t inreg, outreg;
    struct ebios_dapa *dapa;
    void *buf;
    int rv = -1;

    buf = lmalloc(SECTOR * size);
    if (!buf)
	return -1;

    dapa = lmalloc(sizeof(*dapa));
    if (!dapa)
	goto out;

    memcpy(buf, data, SECTOR * size);
    memset(&inreg, 0, sizeof inreg);

    if (drive_info->ebios) {
	dapa->len = sizeof(*dapa);
	dapa->count = size;
	dapa->off = OFFS(buf);
	dapa->seg = SEG(buf);
	dapa->lba = lba;

	inreg.esi.w[0] = OFFS(dapa);
	inreg.ds = SEG(dapa);
	inreg.edx.b[0] = drive_info->disk;
	inreg.eax.w[0] = 0x4300;	/* Extended write */
    } else {
	unsigned int c, h, s;

	if (!drive_info->cbios) {	// XXX errno
	    /* We failed to get the geometry */
	    if (lba)
		goto out;	/* Can only write MBR */

	    s = 1;
	    h = 0;
	    c = 0;
	} else
	    lba_to_chs(drive_info, lba, &s, &h, &c);

	// XXX errno
	if (s > 63 || h > 256 || c > 1023)
	    goto out;

	inreg.eax.w[0] = 0x0301;	/* Write one sector */
	inreg.ecx.b[1] = c & 0xff;
	inreg.ecx.b[0] = s + (c >> 6);
	inreg.edx.b[1] = h;
	inreg.edx.b[0] = drive_info->disk;
	inreg.ebx.w[0] = OFFS(buf);
	inreg.es = SEG(buf);
    }

    /* Perform the write */
    if (int13_retry(&inreg, &outreg)) {
	errno_disk = outreg.eax.b[1];	/* Give up */
    } else
	rv = size;
out:
    lfree(dapa);
    lfree(buf);
    return rv;
}
Example #29
0
Regs
int21(Regs reg)
{
    static int numFiles = 0;
    static FILE *files[16];

    consolePollEvents();

    switch (reg.ah) {

    case 0x06: {              /* Direct console input/output (Only input supported) */
        if (reg.dl == 0xFF) {
            if (keyboard.eventWaiting) {
                reg.al = keyboard.ascii;
                CLR_ZF;
                keyboard.eventWaiting = 0;
            } else {
                reg.al = 0;
                SET_ZF;
            }
        }
        break;
    }

    case 0x25: {              /* Set interrupt vector */
        /* Ignored. Robot Odyssey uses this to set the INT 24h error handler. */
        break;
    }

    case 0x2C: {              /* Get system time */
        /*
         * XXX: This is supposed to return wallclock time, but Robot Odyssey's
         *      menu just uses this for calculated delays- so the offset from
         *      real time is not important.
         */
        uint32_t ticks = SDL_GetTicks();
        uint32_t seconds = ticks / 1000;
        uint32_t minutes = seconds / 60;
        uint32_t hours = minutes / 60;
        reg.ch = hours % 24;
        reg.cl = minutes % 60;
        reg.dh = seconds % 60;
        reg.dl = (ticks / 10) % 100;
        break;
    }


    case 0x3D: {              /* Open File */
        int fd = numFiles;
        const char *name = mem + SEG(reg.ds, reg.dx);

        printf("DOS: Open file %04x:%04x='%s' -> #%d\n",
               reg.ds, reg.dx, name, fd);

        numFiles++;
        files[fd] = fopen(name, "rb");
        reg.ax = fd;
        CLR_CF;

        if (!files[fd]) {
            perror("fopen");
            exit(1);
        }
        break;
    }

    case 0x3E: {              /* Close File */
        printf("DOS: Close file #%d\n", reg.bx);
        CLR_CF;
        break;
    }

    case 0x3F: {              /* Read File */
        int fd = reg.bx;
        int len = reg.cx;
        void *dest = mem + SEG(reg.ds, reg.dx);
        int result = fread(dest, 1, len, files[fd]);

        printf("DOS: Read %d bytes from file #%d -> %d bytes at %04x:%04x\n",
               len, fd, result, reg.ds, reg.dx);
        reg.ax = result;
        CLR_CF;
        break;
    }

    case 0x4C: {              /* Exit with return code */
        longjmp(dosExitJump, 0x100 | reg.al);
        break;
    }

    default:
        printf("DOS: Unsupported! ax=0x%04x\n", reg.ax);
        break;
    }
    return reg;
}
Example #30
0
void POINT_EDITOR::addCorner( const VECTOR2I& aBreakPoint )
{
    EDA_ITEM* item = m_editPoints->GetParent();
    const SELECTION& selection = m_selectionTool->GetSelection();

    if( item->Type() == PCB_ZONE_AREA_T )
    {
        getEditFrame<PCB_BASE_FRAME>()->OnModify();
        getEditFrame<PCB_BASE_FRAME>()->SaveCopyInUndoList( selection.items, UR_CHANGED );

        ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
        CPolyLine* outline = zone->Outline();

        // Handle the last segment, so other segments can be easily handled in a loop
        unsigned int nearestIdx = outline->GetCornersCount() - 1, nextNearestIdx = 0;
        SEG side( VECTOR2I( outline->GetPos( nearestIdx ) ),
                  VECTOR2I( outline->GetPos( nextNearestIdx ) ) );
        unsigned int nearestDist = side.Distance( aBreakPoint );

        for( int i = 0; i < outline->GetCornersCount() - 1; ++i )
        {
            side = SEG( VECTOR2I( outline->GetPos( i ) ), VECTOR2I( outline->GetPos( i + 1 ) ) );

            unsigned int distance = side.Distance( aBreakPoint );
            if( distance < nearestDist )
            {
                nearestDist = distance;
                nearestIdx = i;
                nextNearestIdx = i + 1;
            }
        }

        // Find the point on the closest segment
        VECTOR2I sideOrigin( outline->GetPos( nearestIdx ) );
        VECTOR2I sideEnd( outline->GetPos( nextNearestIdx ) );
        SEG nearestSide( sideOrigin, sideEnd );
        VECTOR2I nearestPoint = nearestSide.NearestPoint( aBreakPoint );

        // Do not add points that have the same coordinates as ones that already belong to polygon
        // instead, add a point in the middle of the side
        if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
            nearestPoint = ( sideOrigin + sideEnd ) / 2;

        outline->InsertCorner( nearestIdx, nearestPoint.x, nearestPoint.y );
    }

    else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T )
    {
        bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T;
        PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();

        frame->OnModify();

        if( moduleEdge )
            frame->SaveCopyInUndoList( getModel<BOARD>()->m_Modules, UR_MODEDIT );
        else
            frame->SaveCopyInUndoList( selection.items, UR_CHANGED );

        DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );

        if( segment->GetShape() == S_SEGMENT )
        {
            SEG seg( segment->GetStart(), segment->GetEnd() );
            VECTOR2I nearestPoint = seg.NearestPoint( aBreakPoint );

            // Move the end of the line to the break point..
            segment->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );

            // and add another one starting from the break point
            DRAWSEGMENT* newSegment;

            if( moduleEdge )
            {
                EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( segment );
                assert( segment->GetParent()->Type() == PCB_MODULE_T );
                newSegment = new EDGE_MODULE( *edge );
                edge->SetLocalCoord();
            }
            else
            {
                newSegment = new DRAWSEGMENT( *segment );
            }

            newSegment->ClearSelected();
            newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
            newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );

            if( moduleEdge )
            {
                static_cast<EDGE_MODULE*>( newSegment )->SetLocalCoord();
                getModel<BOARD>()->m_Modules->Add( newSegment );
            }
            else
            {
                getModel<BOARD>()->Add( newSegment );
            }

            getView()->Add( newSegment );
        }
    }
}