coreboot-kgpe-d16/payloads/libpayload/curses/PDCurses-3.4/dos/pdcutil.c
Patrick Georgi 3b77b723ca libpayload: Add PDCurses and ncurses' libform/libmenu
PDCurses provides an alternative implementation of the curses library
standard in addition to tinycurses.
Where tinycurses is really tiny, PDCurses is more complete and provides
virtually unlimited windows and the full API.
The PDCurses code is brought in "vanilla", with all local changes
residing in curses/pdcurses-backend/

In addition to a curses library, this change also provides libpanel (as
part of the PDCurses code), and libform and libmenu which were derived
from ncurses-5.9.
As they rely on ncurses internals (and PDCurses is not ncurses), more
changes were required for these libraries to work.

The build system is extended to install the right set of header files
depending on the selected curses implementation.

Change-Id: I9e5b920f94b6510da01da2f656196a993170d1c5
Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>
Reviewed-on: http://review.coreboot.org/106
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marcj303@gmail.com>
2011-08-04 08:10:41 +02:00

105 lines
1.8 KiB
C

/* Public Domain Curses */
#include "pdcdos.h"
RCSID("$Id: pdcutil.c,v 1.24 2008/07/13 16:08:17 wmcbrine Exp $")
void PDC_beep(void)
{
PDCREGS regs;
PDC_LOG(("PDC_beep() - called\n"));
regs.W.ax = 0x0e07; /* Write ^G in TTY fashion */
regs.W.bx = 0;
PDCINT(0x10, regs);
}
void PDC_napms(int ms)
{
PDCREGS regs;
long goal, start, current;
PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
goal = DIVROUND((long)ms, 50);
if (!goal)
goal++;
start = getdosmemdword(0x46c);
goal += start;
while (goal > (current = getdosmemdword(0x46c)))
{
if (current < start) /* in case of midnight reset */
return;
regs.W.ax = 0x1680;
PDCINT(0x2f, regs);
PDCINT(0x28, regs);
}
}
const char *PDC_sysname(void)
{
return "DOS";
}
#ifdef __DJGPP__
unsigned char getdosmembyte(int offset)
{
unsigned char b;
dosmemget(offset, sizeof(unsigned char), &b);
return b;
}
unsigned short getdosmemword(int offset)
{
unsigned short w;
dosmemget(offset, sizeof(unsigned short), &w);
return w;
}
unsigned long getdosmemdword(int offset)
{
unsigned long dw;
dosmemget(offset, sizeof(unsigned long), &dw);
return dw;
}
void setdosmembyte(int offset, unsigned char b)
{
dosmemput(&b, sizeof(unsigned char), offset);
}
void setdosmemword(int offset, unsigned short w)
{
dosmemput(&w, sizeof(unsigned short), offset);
}
#endif
#if defined(__WATCOMC__) && defined(__386__)
void PDC_dpmi_int(int vector, pdc_dpmi_regs *rmregs)
{
union REGPACK regs = {0};
rmregs->w.ss = 0;
rmregs->w.sp = 0;
rmregs->w.flags = 0;
regs.w.ax = 0x300;
regs.h.bl = vector;
regs.x.edi = FP_OFF(rmregs);
regs.x.es = FP_SEG(rmregs);
intr(0x31, &regs);
}
#endif