diff options
author | Keith Packard <keithp@keithp.com> | 2003-10-14 05:08:35 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2003-10-14 05:08:35 +0000 |
commit | 109b94951654171ada94e2ffb29568b8a1bcde77 (patch) | |
tree | 839f0c2933a071b9af1511226ac7e160d8dde82f | |
parent | 4b844cafb2516139c8407822b61939cd6c743742 (diff) |
-Wall fixes. Might have fixed VESA based DPMS code as a result
-rw-r--r-- | hw/kdrive/vesa/vbe.c | 201 | ||||
-rw-r--r-- | hw/kdrive/vesa/vbe.h | 23 | ||||
-rw-r--r-- | hw/kdrive/vesa/vesa.c | 36 | ||||
-rw-r--r-- | hw/kdrive/vesa/vesa.h | 34 | ||||
-rw-r--r-- | hw/kdrive/vesa/vga.c | 4 | ||||
-rw-r--r-- | hw/kdrive/vesa/vga.h | 4 | ||||
-rw-r--r-- | hw/kdrive/vesa/vm86.c | 11 |
7 files changed, 169 insertions, 144 deletions
diff --git a/hw/kdrive/vesa/vbe.c b/hw/kdrive/vesa/vbe.c index 3e88adae1..bcd400333 100644 --- a/hw/kdrive/vesa/vbe.c +++ b/hw/kdrive/vesa/vbe.c @@ -58,7 +58,6 @@ VbeGetVmib (Vm86InfoPtr vi, int mode, VbeModeInfoBlock *vmib) { int code; int mark; - int vib_base; int vmib_base; VbeModeInfoBlock *vmib_low; @@ -79,6 +78,101 @@ VbeGetVmib (Vm86InfoPtr vi, int mode, VbeModeInfoBlock *vmib) return code; } +static int +VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib) +{ + U32 i, p; + unsigned char c; + int error = 0; + + ErrorF("VBE version %c.%c (", + ((vib->VbeVersion >> 8) & 0xFF) + '0', + (vib->VbeVersion & 0xFF)+'0'); + p = vib->OemStringPtr; + for(i = 0; 1; i++) { + c = Vm86Memory(vi, MAKE_POINTER_1(p+i)); + if(!c) break; + if (c >= ' ') + ErrorF("%c", c); + if (i > 32000) { + error = 1; + break; + } + } + ErrorF(")\n"); + ErrorF("DAC is %s, controller is %sVGA compatible%s\n", + (vib->Capabilities[0]&1)?"fixed":"switchable", + (vib->Capabilities[0]&2)?"not ":"", + (vib->Capabilities[0]&3)?", RAMDAC causes snow":""); + ErrorF("Total memory: %lu kilobytes\n", 64L*vib->TotalMemory); + if(error) + return -1; + return 0; +} + +#if 0 +static int +VbeReportModeInfo(Vm86InfoPtr vi, U16 mode, VbeModeInfoBlock *vmib) +{ + int supported = (vmib->ModeAttributes&0x1)?1:0; + int colour = (vmib->ModeAttributes&0x8)?1:0; + int graphics = (vmib->ModeAttributes&0x10)?1:0; + int vga_compatible = !((vmib->ModeAttributes&0x20)?1:0); + int linear_fb = (vmib->ModeAttributes&0x80)?1:0; + + ErrorF("0x%04X: %dx%dx%d%s", + (unsigned)mode, + (int)vmib->XResolution, (int)vmib->YResolution, + (int)vmib->BitsPerPixel, + colour?"":" (monochrome)", + graphics?"":" (graphics)", + vga_compatible?"":" (vga compatible)", + linear_fb?"":" (linear frame buffer)"); + switch(vmib->MemoryModel) { + case 0: + ErrorF(" text mode (%dx%d)", + (int)vmib->XCharSize, (int)vmib->YCharSize); + break; + case 1: + ErrorF(" CGA graphics"); + break; + case 2: + ErrorF(" Hercules graphics"); + break; + case 3: + ErrorF(" Planar (%d planes)", vmib->NumberOfPlanes); + break; + case 4: + ErrorF(" PseudoColor"); + break; + case 5: + ErrorF(" Non-chain 4, 256 colour"); + break; + case 6: + if(vmib->DirectColorModeInfo & 1) + ErrorF(" DirectColor"); + else + ErrorF(" TrueColor"); + ErrorF(" [%d:%d:%d:%d]", + vmib->RedMaskSize, vmib->GreenMaskSize, vmib->BlueMaskSize, + vmib->RsvdMaskSize); + if(vmib->DirectColorModeInfo & 2) + ErrorF(" (reserved bits are reserved)"); + break; + case 7: ErrorF("YUV"); + break; + default: + ErrorF("unknown MemoryModel 0x%X ", vmib->MemoryModel); + } + if(!supported) + ErrorF(" (unsupported)"); + else if(!linear_fb) + ErrorF(" (no linear framebuffer)"); + ErrorF("\n"); + return 0; +} +#endif + void VbeReportInfo (Vm86InfoPtr vi) { @@ -95,7 +189,6 @@ VbeGetNmode (Vm86InfoPtr vi) { VbeInfoBlock vib; int code; - int ret = 0; unsigned int p; int n; int mode; @@ -121,7 +214,6 @@ VbeGetModes (Vm86InfoPtr vi, VesaModePtr modes, int nmode) { VbeInfoBlock vib; int code; - int ret = 0; unsigned int p; int n; int mode; @@ -262,7 +354,6 @@ VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size, CARD3 int size; int pagesize = getpagesize(); int before, after; - int devmem; if (VbeGetVib (vi, &vib) < 0) return 0; @@ -329,7 +420,7 @@ VbeSetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries U8 *palette_scratch; int mark; int palette_base; - int i, j, code; + int i, code; if(number == 0) return 0; @@ -374,7 +465,7 @@ VbeGetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries U8 *palette_scratch; int mark; int palette_base; - int i, j, code; + int i, code; if(number == 0) return 0; @@ -513,10 +604,15 @@ static const int VbeDPMSModes[4] = { }; Bool -VbeDPMS(Vm86InfoPtr vi, VbeInfoBlock *vib, int mode) +VbeDPMS(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode) { - int code; + int code; + VbeInfoBlock vib; + code = VbeGetVib (vi, &vib); + if (code < 0) + return FALSE; + /* * Check which modes are supported */ @@ -547,95 +643,6 @@ VbeDPMS(Vm86InfoPtr vi, VbeInfoBlock *vib, int mode) return TRUE; } -int -VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib) -{ - U32 i, p; - unsigned char c; - int error; - ErrorF("VBE version %c.%c (", - ((vib->VbeVersion >> 8) & 0xFF) + '0', - (vib->VbeVersion & 0xFF)+'0'); - p = vib->OemStringPtr; - for(i = 0; 1; i++) { - c = Vm86Memory(vi, MAKE_POINTER_1(p+i)); - if(!c) break; - if (c >= ' ') - ErrorF("%c", c); - if (i > 32000) { - error = 1; - break; - } - } - ErrorF(")\n"); - ErrorF("DAC is %s, controller is %sVGA compatible%s\n", - (vib->Capabilities[0]&1)?"fixed":"switchable", - (vib->Capabilities[0]&2)?"not ":"", - (vib->Capabilities[0]&3)?", RAMDAC causes snow":""); - ErrorF("Total memory: %lu kilobytes\n", 64L*vib->TotalMemory); - if(error) - return -1; - return 0; -} - -int -VbeReportModeInfo(Vm86InfoPtr vi, U16 mode, VbeModeInfoBlock *vmib) -{ - int supported = (vmib->ModeAttributes&0x1)?1:0; - int colour = (vmib->ModeAttributes&0x8)?1:0; - int graphics = (vmib->ModeAttributes&0x10)?1:0; - int vga_compatible = !((vmib->ModeAttributes&0x20)?1:0); - int linear_fb = (vmib->ModeAttributes&0x80)?1:0; - - ErrorF("0x%04X: %dx%dx%d%s", - (unsigned)mode, - (int)vmib->XResolution, (int)vmib->YResolution, - (int)vmib->BitsPerPixel, - colour?"":" (monochrome)"); - switch(vmib->MemoryModel) { - case 0: - ErrorF(" text mode (%dx%d)", - (int)vmib->XCharSize, (int)vmib->YCharSize); - break; - case 1: - ErrorF(" CGA graphics"); - break; - case 2: - ErrorF(" Hercules graphics"); - break; - case 3: - ErrorF(" Planar (%d planes)", vmib->NumberOfPlanes); - break; - case 4: - ErrorF(" PseudoColor"); - break; - case 5: - ErrorF(" Non-chain 4, 256 colour"); - break; - case 6: - if(vmib->DirectColorModeInfo & 1) - ErrorF(" DirectColor"); - else - ErrorF(" TrueColor"); - ErrorF(" [%d:%d:%d:%d]", - vmib->RedMaskSize, vmib->GreenMaskSize, vmib->BlueMaskSize, - vmib->RsvdMaskSize); - if(vmib->DirectColorModeInfo & 2) - ErrorF(" (reserved bits are reserved)"); - break; - case 7: ErrorF("YUV"); - break; - default: - ErrorF("unknown MemoryModel 0x%X ", vmib->MemoryModel); - } - if(!supported) - ErrorF(" (unsupported)"); - else if(!linear_fb) - ErrorF(" (no linear framebuffer)"); - ErrorF("\n"); - return 0; -} - int VbeDoInterrupt10(Vm86InfoPtr vi) { diff --git a/hw/kdrive/vesa/vbe.h b/hw/kdrive/vesa/vbe.h index 500938e41..8ec82dca7 100644 --- a/hw/kdrive/vesa/vbe.h +++ b/hw/kdrive/vesa/vbe.h @@ -121,12 +121,12 @@ VbeGetNmode (Vm86InfoPtr vi); int VbeGetModes (Vm86InfoPtr vi, VesaModePtr modes, int nmode); -int -VbeGetModeInfo(Vm86InfoPtr vi, int m, VesaModePtr mode); - VbeInfoPtr VbeInit (Vm86InfoPtr vi); +void +VbeCleanup (Vm86InfoPtr vi, VbeInfoPtr vbe); + int VbeSetMode (Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int linear, int direct); @@ -134,30 +134,27 @@ int VbeGetMode(Vm86InfoPtr vi, int *mode); void * -VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *size, CARD32 *phys); +VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size, CARD32 *ret_phys); void VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb); int VbeSetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries); - + int VbeGetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries); - + int VbeSetPaletteOptions(Vm86InfoPtr vi, VbeInfoPtr vbe, U8 bits, int wait); void * VbeSetWindow(Vm86InfoPtr vi, VbeInfoPtr vbe, int offset, int purpose, int *size_return); -int -VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib); - -int -VbeReportModeInfo(Vm86InfoPtr vi, U16 mode, VbeModeInfoBlock *vmib); - +Bool +VbeDPMS(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode); + int VbeDoInterrupt10(Vm86InfoPtr vi); - + #endif diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c index 52cc3bcfa..747575686 100644 --- a/hw/kdrive/vesa/vesa.c +++ b/hw/kdrive/vesa/vesa.c @@ -25,6 +25,8 @@ THE SOFTWARE. #include <config.h> #endif #include "vesa.h" +#include "vga.h" +#include "vbe.h" #ifdef RANDR #include <randrstr.h> #endif @@ -93,11 +95,14 @@ vesaReportMode (VesaModePtr mode) int vga_compatible = !((mode->ModeAttributes&MODE_VGA)?1:0); int linear_fb = (mode->ModeAttributes&MODE_LINEAR)?1:0; - ErrorF("0x%04X: %dx%dx%d%s", + ErrorF("0x%04X: %dx%dx%d%s%s", (unsigned)mode->mode, (int)mode->XResolution, (int)mode->YResolution, vesaDepth (mode), - colour?"":" (monochrome)"); + colour?"":" (monochrome)", + graphics?"":" (graphics)", + vga_compatible?"":" (vga compatible)", + linear_fb?"":" (linear frame buffer)"); switch(mode->MemoryModel) { case MEMORY_TEXT: ErrorF(" text mode"); @@ -201,8 +206,6 @@ vesaGetModes (Vm86InfoPtr vi, int *ret_nmode) Bool vesaInitialize (KdCardInfo *card, VesaCardPrivPtr priv) { - int code; - priv->vi = Vm86Setup(vesa_map_holes); if(!priv->vi) goto fail; @@ -349,6 +352,7 @@ vesaModeGood (KdScreenInfo *screen, { return TRUE; } + return FALSE; } #define vabs(a) ((a) >= 0 ? (a) : -(a)) @@ -424,9 +428,7 @@ vesaSelectMode (KdScreenInfo *screen) Bool vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr) { - VesaCardPrivPtr priv = screen->card->driver; VesaModePtr mode; - Pixel allbits; screen->driver = pscr; @@ -568,7 +570,6 @@ vesaSetWindowLinear (ScreenPtr pScreen, CARD32 *size) { KdScreenPriv(pScreen); - VesaCardPrivPtr priv = pScreenPriv->card->driver; VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; *size = pscr->mode.BytesPerScanLine; @@ -668,7 +669,6 @@ vesaWindowCga (ScreenPtr pScreen, void *closure) { KdScreenPriv(pScreen); - VesaCardPrivPtr priv = pScreenPriv->card->driver; VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; int line; @@ -685,21 +685,18 @@ vesaUpdateMono (ScreenPtr pScreen, { RegionPtr damage = &pBuf->damage; PixmapPtr pShadow = pBuf->pPixmap; - shadowScrPriv(pScreen); int nbox = REGION_NUM_RECTS (damage); BoxPtr pbox = REGION_RECTS (damage); FbBits *shaBase, *shaLine, *sha; - FbBits s; FbStride shaStride; int scrBase, scrLine, scr; int shaBpp; int shaXoff, shaYoff; /* XXX assumed to be zero */ int x, y, w, h, width; int i; - FbBits *winBase, *winLine, *win; + FbBits *winBase = 0, *win; CARD32 winSize; FbBits bits; - int plane; fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); while (nbox--) @@ -798,7 +795,6 @@ vesaConfigureScreen (ScreenPtr pScreen) { KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; - VesaCardPrivPtr priv = pScreenPriv->card->driver; VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; KdMouseMatrix m; @@ -840,11 +836,9 @@ vesaLayerCreate (ScreenPtr pScreen) { KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; - VesaCardPrivPtr priv = pScreenPriv->card->driver; VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - LayerPtr pLayer; ShadowUpdateProc update; - ShadowWindowProc window; + ShadowWindowProc window = 0; PixmapPtr pPixmap; int kind; @@ -1144,7 +1138,7 @@ vesaRandRSetConfig (ScreenPtr pScreen, RRScreenSizePtr pSize) { KdScreenPriv(pScreen); - VesaModePtr mode; + VesaModePtr mode = 0; KdScreenInfo *screen = pScreenPriv->screen; VesaCardPrivPtr priv = pScreenPriv->card->driver; VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; @@ -1346,9 +1340,6 @@ vesaRandRInit (ScreenPtr pScreen) Bool vesaInitScreen(ScreenPtr pScreen) { - KdScreenPriv(pScreen); - VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; - if (!LayerStartInit (pScreen)) return FALSE; @@ -1417,7 +1408,6 @@ vesaEnable(ScreenPtr pScreen) VesaCardPrivPtr priv = pScreenPriv->card->driver; VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; KdScreenInfo *screen = pScreenPriv->screen; - int code; int i; CARD32 size; char *p; @@ -1615,7 +1605,6 @@ void vesaPreserve(KdCardInfo *card) { VesaCardPrivPtr priv = card->driver; - int code; /* The framebuffer might not be valid at this point, so we cannot save the VGA fonts now; we do it in vesaEnable. */ @@ -1678,7 +1667,6 @@ void vesaScreenFini(KdScreenInfo *screen) { VesaScreenPrivPtr pscr = screen->driver; - VesaCardPrivPtr priv = screen->card->driver; vesaUnmapFramebuffer (screen); screen->fb[0].depth = pscr->origDepth; @@ -1779,7 +1767,7 @@ vesaGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) KdScreenPriv(pScreen); VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; VesaCardPrivPtr priv = pScreenPriv->card->driver; - int first, i, j, k; + int i; int red, green, blue; int min, max; int p; diff --git a/hw/kdrive/vesa/vesa.h b/hw/kdrive/vesa/vesa.h index 72339459a..30222d41b 100644 --- a/hw/kdrive/vesa/vesa.h +++ b/hw/kdrive/vesa/vesa.h @@ -117,6 +117,25 @@ vesaInitialize(KdCardInfo *card, VesaCardPrivPtr priv); Bool vesaCardInit(KdCardInfo *card); +int +vesaDepth (VesaModePtr mode); + +Bool +vesaModeGood (KdScreenInfo *screen, + VesaModePtr a); + +int +vesaSizeError (KdScreenInfo *screen, + VesaModePtr a); + +Bool +vesaModeBetter (KdScreenInfo *screen, + VesaModePtr a, + VesaModePtr b); + +VesaModePtr +vesaSelectMode (KdScreenInfo *screen); + Bool vesaInitialize (KdCardInfo *card, VesaCardPrivPtr priv); @@ -130,12 +149,19 @@ LayerPtr vesaLayerCreate (ScreenPtr pScreen); Bool +vesaMapFramebuffer (KdScreenInfo *screen); + +Bool vesaInitScreen(ScreenPtr pScreen); Bool vesaFinishInitScreen(ScreenPtr pScreen); Bool +vesaSetMode (ScreenPtr pScreen, + VesaModePtr mode); + +Bool vesaEnable(ScreenPtr pScreen); Bool @@ -165,4 +191,12 @@ vesaGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs); int vesaProcessArgument (int argc, char **argv, int i); +#ifdef RANDR +Bool +vesaRandRSetConfig (ScreenPtr pScreen, + Rotation randr, + int rate, + RRScreenSizePtr pSize); +#endif + #endif /* _VESA_H_ */ diff --git a/hw/kdrive/vesa/vga.c b/hw/kdrive/vesa/vga.c index aad2756de..500746774 100644 --- a/hw/kdrive/vesa/vga.c +++ b/hw/kdrive/vesa/vga.c @@ -115,14 +115,14 @@ VgaGetMode (Vm86InfoPtr vi, int *mode) return 0; } -int +void VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask) { asm volatile ("outb %b0,%w1" : : "a" (2), "d" (0x3c4)); asm volatile ("outb %b0,%w1" : : "a" (mask), "d" (0x3c5)); } -int +void VgaSetReadPlaneMap(Vm86InfoPtr vi, int map) { asm volatile ("outb %b0,%w1" : : "a" (4), "d" (0x3ce)); diff --git a/hw/kdrive/vesa/vga.h b/hw/kdrive/vesa/vga.h index 80d6bb42a..ca000904b 100644 --- a/hw/kdrive/vesa/vga.h +++ b/hw/kdrive/vesa/vga.h @@ -37,10 +37,10 @@ VgaSetMode(Vm86InfoPtr vi, int mode); int VgaGetMode (Vm86InfoPtr vi, int *mode); -int +void VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask); -int +void VgaSetReadPlaneMap(Vm86InfoPtr vi, int map); int diff --git a/hw/kdrive/vesa/vm86.c b/hw/kdrive/vesa/vm86.c index da85b83a9..3af5042e0 100644 --- a/hw/kdrive/vesa/vm86.c +++ b/hw/kdrive/vesa/vm86.c @@ -328,8 +328,8 @@ vm86_outl(U16 port, U32 value) #define SEG_FS 6 #define REP 1 #define REPNZ 2 -#define SET_8(_x, _y) (_x) = (_x & ~0xFF) | (_y & 0xFF); -#define SET_16(_x, _y) (_x) = (_x & ~0xFFFF) | (_y & 0xFFFF); +#define SET_8(_x, _y) (_x) = ((_x) & ~0xFF) | ((_y) & 0xFF); +#define SET_16(_x, _y) (_x) = ((_x) & ~0xFFFF) | ((_y) & 0xFFFF); #define INC_IP(_i) SET_16(regs->eip, (regs->eip + _i)) #define AGAIN INC_IP(1); goto again; @@ -340,8 +340,6 @@ vm86_emulate(Vm86InfoPtr vi) U8 opcode; int size; int pref_seg = 0, pref_rep = 0, pref_66 = 0, pref_67 = 0; - U32 count; - int code; again: if(!Vm86IsMemory(vi, MAKE_POINTER(regs->cs, regs->eip))) { @@ -412,7 +410,7 @@ vm86_emulate(Vm86InfoPtr vi) goto again; } else { SET_16(regs->ecx, regs->ecx - 1); - if(regs->ecx & 0xFFFF != 0) + if((regs->ecx & 0xFFFF) != 0) goto again; } } @@ -470,7 +468,7 @@ vm86_emulate(Vm86InfoPtr vi) goto again; } else { SET_16(regs->ecx, regs->ecx - 1); - if(regs->ecx & 0xFFFF != 0) + if((regs->ecx & 0xFFFF) != 0) goto again; } } @@ -571,6 +569,7 @@ Vm86Memory(Vm86InfoPtr vi, U32 i) return HM(vi, i); else { ErrorF("Reading unmapped memory at 0x%08X\n", i); + return 0; } } |