|
|
1.1 ! root 1: /******************************Module*Header*******************************\ ! 2: * Module Name: hardware.c ! 3: * ! 4: * Hardware dependent initialization ! 5: * ! 6: * Copyright (c) 1992 Microsoft Corporation ! 7: * ! 8: \**************************************************************************/ ! 9: ! 10: #include "driver.h" ! 11: ! 12: VOID vBlowCache(PPDEV ppdev); ! 13: ! 14: /***************************************************************************** ! 15: * vSaveOffScreenMemory ! 16: ****************************************************************************/ ! 17: VOID vSaveOffScreenMemory(PPDEV ppdev) ! 18: { ! 19: WORD cmd; ! 20: ULONG i; ! 21: WORD* pwBuffer; ! 22: ! 23: DISPDBG((2, "S3.DLL!vSaveOffScreenMemory - Entry\n")); ! 24: ! 25: if (ppdev->pOffScreenSaveBuffer == NULL) ! 26: { ! 27: ppdev->pOffScreenSaveBuffer = (PWORD) LocalAlloc(LPTR, (OFF_SCREEN_CX * OFF_SCREEN_CY)); ! 28: ! 29: if (ppdev->pOffScreenSaveBuffer == NULL) ! 30: { ! 31: DISPDBG((0, "S3.DLL: vSaveOffScreenMemory - LocalAlloc failed \n")); ! 32: return; ! 33: } ! 34: } ! 35: ! 36: // Transfer the image (that happens to be the off screen memory) ! 37: // from the screen to host memory. ! 38: ! 39: cmd = RECTANGLE_FILL | BYTE_SWAP | BUS_SIZE_16 | ! 40: DRAWING_DIR_TBLRXM | DIR_TYPE_XY | WAIT | ! 41: DRAW | LAST_PIXEL_ON | READ; ! 42: ! 43: FIFOWAIT(FIFO_7_EMPTY); ! 44: ! 45: TEST_AND_SET_RD_MASK(0xff); ! 46: OUTPW (MULTIFUNC_CNTL, (DATA_EXTENSION | ALL_ONES)); ! 47: ! 48: OUTPW (CUR_X, 0); ! 49: OUTPW (CUR_Y, OFF_SCREEN_Y); ! 50: OUTPW (RECT_WIDTH, (OFF_SCREEN_CX - 1)); ! 51: OUTPW (MULTIFUNC_CNTL, (RECT_HEIGHT | (OFF_SCREEN_CY - 1))); ! 52: ! 53: OUTPW (CMD, cmd); ! 54: ! 55: // Wait for the Data Available. ! 56: ! 57: while (!(INPW(GP_STAT) & READ_DATA_AVAILABLE)); ! 58: ! 59: // Now transfer the data from the screen to the host memory bitmap. ! 60: ! 61: // NOTE: We call vDataPortIn once for each scan instead of doing just ! 62: // one large call to vDataPortIn because for some reason some machines ! 63: // choke on a REP INSW of that large a size -- the S3 gets into a mode ! 64: // such that even when the transfer is completely done, it still ! 65: // claims there's more data to be sent. This happens on the machine ! 66: // regardless of S3 chip type, but this seems to be an effective work- ! 67: // around for all cases: ! 68: ! 69: pwBuffer = (WORD*) ppdev->pOffScreenSaveBuffer; ! 70: for (i = OFF_SCREEN_CY; i > 0; i--) ! 71: { ! 72: vDataPortIn(ppdev, pwBuffer, OFF_SCREEN_CX / 2); ! 73: pwBuffer += OFF_SCREEN_CX / 2; ! 74: } ! 75: ! 76: } ! 77: ! 78: ! 79: /***************************************************************************** ! 80: * ! 81: ****************************************************************************/ ! 82: VOID vRestoreOffScreenMemory(PPDEV ppdev) ! 83: { ! 84: WORD cmd; ! 85: ! 86: ! 87: DISPDBG((2, "S3.DLL!vRestoreOffScreenMemory - Entry\n")); ! 88: ! 89: // If there is no buffer then just return. ! 90: ! 91: if (ppdev->pOffScreenSaveBuffer == NULL) { ! 92: ! 93: // This will happen when we're in a low memory condition. ! 94: ! 95: vBlowCache(ppdev); ! 96: return; ! 97: } ! 98: ! 99: // Transfer the image (that happens to be the off screen memory) ! 100: // from host memory to the off screen memory. ! 101: ! 102: cmd = RECTANGLE_FILL | BYTE_SWAP | BUS_SIZE_16 | ! 103: DRAWING_DIR_TBLRXM | DIR_TYPE_XY | WAIT | ! 104: DRAW | LAST_PIXEL_ON | WRITE; ! 105: ! 106: FIFOWAIT(FIFO_8_EMPTY); ! 107: ! 108: TEST_AND_SET_WRT_MASK(0xff); ! 109: OUTPW (MULTIFUNC_CNTL, (DATA_EXTENSION | ALL_ONES)); ! 110: TEST_AND_SET_FRGD_MIX(SRC_CPU_DATA | OVERPAINT); ! 111: ! 112: OUTPW (CUR_X, 0); ! 113: OUTPW (CUR_Y, OFF_SCREEN_Y); ! 114: OUTPW (RECT_WIDTH, (OFF_SCREEN_CX - 1)); ! 115: OUTPW (MULTIFUNC_CNTL, (RECT_HEIGHT | (OFF_SCREEN_CY - 1))); ! 116: ! 117: OUTPW (CMD, cmd); ! 118: ! 119: // Now transfer the data from the screen to the host memory bitmap. ! 120: ! 121: vDataPortOut(ppdev, ppdev->pOffScreenSaveBuffer, ((OFF_SCREEN_CX * OFF_SCREEN_CY)/2)); ! 122: ! 123: // We free this up for two reasons: ! 124: // 1) Going to/from Full Screen mode is slow, no one will ! 125: // notice the Alloc/Free. ! 126: // 2) It's not nice to keep a 256K chunk of memory around when ! 127: // one really doesn't need it. ! 128: // ! 129: ! 130: LocalFree(ppdev->pOffScreenSaveBuffer); ! 131: ppdev->pOffScreenSaveBuffer = NULL; ! 132: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.