Index: branches/rewrite/i386/libsaio/cache.c =================================================================== --- branches/rewrite/i386/libsaio/cache.c (revision 1088) +++ branches/rewrite/i386/libsaio/cache.c (revision 1089) @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 2.0 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* - * cache.c - A simple cache for file systems meta-data. - * - * Copyright (c) 2000 Apple Computer, Inc. - * - * DRI: Josh de Cesare - */ - -#include -// #include - -struct CacheEntry { - CICell ih; - long time; - long long offset; -}; -typedef struct CacheEntry CacheEntry; - -#define kCacheSize (0x100000) -#define kCacheMinBlockSize (0x200) -#define kCacheMaxBlockSize (0x8000) -#define kCacheMaxEntries (kCacheSize / kCacheMinBlockSize) - -static CICell gCacheIH; -static long gCacheBlockSize; -static long gCacheNumEntries; -static long gCacheTime; - -#ifdef __i386__ -static CacheEntry *gCacheEntries; -static char *gCacheBuffer; -#else -static CacheEntry gCacheEntries[kCacheMaxEntries]; -static char gCacheBuffer[kCacheSize]; -#endif - -#if CACHE_STATS -unsigned long gCacheHits; -unsigned long gCacheMisses; -unsigned long gCacheEvicts; -#endif - -void CacheReset() -{ - gCacheIH = NULL; -} - -void CacheInit( CICell ih, long blockSize ) -{ -#ifdef __i386__ - if ((ih == gCacheIH) && (blockSize == gCacheBlockSize)) - return; -#endif - - if ((blockSize < kCacheMinBlockSize) || - (blockSize > kCacheMaxBlockSize)) - return; - - gCacheBlockSize = blockSize; - gCacheNumEntries = kCacheSize / gCacheBlockSize; - gCacheTime = 0; - -#if CACHE_STATS - gCacheHits = 0; - gCacheMisses = 0; - gCacheEvicts = 0; -#endif - - gCacheIH = ih; - -#ifdef __i386__ - if (!gCacheBuffer) gCacheBuffer = (char *) malloc(kCacheSize); - if (!gCacheEntries) gCacheEntries = (CacheEntry *) malloc(kCacheMaxEntries * sizeof(CacheEntry)); - if ( !gCacheBuffer || !gCacheEntries ) - { - gCacheIH = 0; // invalidate cache - return; - } -#endif - - bzero(gCacheEntries, kCacheMaxEntries * sizeof(CacheEntry)); -} - -long CacheRead( CICell ih, char * buffer, long long offset, - long length, long cache ) -{ - long cnt, oldestEntry = 0, oldestTime, loadCache = 0; - CacheEntry *entry; - - // See if the data can be cached. - if (cache && (gCacheIH == ih) && (length == gCacheBlockSize)) { - // Look for the data in the cache. - for (cnt = 0; cnt < gCacheNumEntries; cnt++) { - entry = &gCacheEntries[cnt]; - if ((entry->ih == ih) && (entry->offset == offset)) { - entry->time = ++gCacheTime; - break; - } - } - - // If the data was found copy it to the caller. - if (cnt != gCacheNumEntries) { - bcopy(gCacheBuffer + cnt * gCacheBlockSize, buffer, gCacheBlockSize); -#if CACHE_STATS - gCacheHits++; -#endif - return gCacheBlockSize; - } - - // Could not find the data in the cache. - loadCache = 1; - } - - // Read the data from the disk. - Seek(ih, offset); - Read(ih, (long)buffer, length); -#if CACHE_STATS - if (cache) gCacheMisses++; -#endif - - // Put the data from the disk in the cache if needed. - if (loadCache) { - // Find a free entry. - oldestTime = gCacheTime; - for (cnt = 0; cnt < gCacheNumEntries; cnt++) { - entry = &gCacheEntries[cnt]; - - // Found a free entry. - if (entry->ih == 0) break; - - if (entry->time < oldestTime) { - oldestTime = entry->time; - oldestEntry = cnt; - } - } - - // If no free entry was found, use the oldest. - if (cnt == gCacheNumEntries) { - cnt = oldestEntry; -#if CACHE_STATS - gCacheEvicts++; -#endif - } - - // Copy the data from disk to the new entry. - entry = &gCacheEntries[cnt]; - entry->ih = ih; - entry->time = ++gCacheTime; - entry->offset = offset; - bcopy(buffer, gCacheBuffer + cnt * gCacheBlockSize, gCacheBlockSize); - } - - return length; -} Index: branches/rewrite/i386/libsaio/vbe.c =================================================================== --- branches/rewrite/i386/libsaio/vbe.c (revision 1088) +++ branches/rewrite/i386/libsaio/vbe.c (revision 1089) @@ -1,310 +0,0 @@ -/* - * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 2.0 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * - * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* - * Copyright 1993 NeXT, Inc. - * All rights reserved. - */ - -#include "libsaio.h" -#include "vbe.h" - -/* - * Various inline routines for video I/O - */ -static inline void -outi (int port, int index, int val) -{ - outw (port, (val << 8) | index); -} - -static inline void -outib (int port, int index, int val) -{ - outb (port, index); - outb (port + 1, val); -} - -static inline int -ini (int port, int index) -{ - outb (port, index); - return inb (port + 1); -} - -static inline void -rmwi (int port, int index, int clear, int set) -{ - outb (port, index); - outb (port + 1, (inb (port + 1) & ~clear) | set); -} - -/* - * Globals - */ -static biosBuf_t bb; - -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); -} - -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); -} - -int getVBEDACFormat(unsigned char *format) -{ - bb.intno = 0x10; - bb.eax.rr = funcGetSetPaletteFormat; - bb.ebx.r.l = subfuncGet; - bios(&bb); - *format = bb.ebx.r.h; - return(bb.eax.r.h); -} - -int setVBEDACFormat(unsigned char format) -{ - bb.intno = 0x10; - bb.eax.rr = funcGetSetPaletteFormat; - bb.ebx.r.l = subfuncSet; - bb.ebx.r.h = format; - bios(&bb); - return(bb.eax.r.h); -} - -/* - * Default GTF parameter values. - */ -#define kCellGranularity 8.0 // character cell granularity -#define kMinVSyncPlusBP 550.0 // min VSync + BP interval (us) -#define kMinFrontPorch 1.0 // minimum front porch in lines(V)/cells(H) -#define kVSyncLines 3.0 // width of VSync in lines -#define kHSyncWidth 8.0 // HSync as a percent of total line width -#define kC 30.0 // C = (C'-J) * (K/256) + J -#define kM 300.0 // M = K/256 * M' - -int Round(double f) -{ - return (int)(f + 0.5); -} - -/* - * from http://www.azillionmonkeys.com/qed/sqroot.html - */ - -double Sqrt( double y ) -{ - double x, z, tempf; - unsigned long *tfptr = ((unsigned long *)&tempf) + 1; - - tempf = y; - *tfptr = (0xbfcdd90a - *tfptr)>>1; /* estimate of 1/sqrt(y) */ - x = tempf; - z = y*0.5; /* hoist out the “/2” */ - x = (1.5*x) - (x*x)*(x*z); /* iteration formula */ - x = (1.5*x) - (x*x)*(x*z); - x = (1.5*x) - (x*x)*(x*z); - x = (1.5*x) - (x*x)*(x*z); - x = (1.5*x) - (x*x)*(x*z); - return x*y; -} - -int generateCRTCTiming( unsigned short width, - unsigned short height, - unsigned long paramValue, - int paramType, - VBECRTCInfoBlock * timing ) -{ - double h_period_est, h_freq, h_period, h_total_pixels, h_sync_pixels; - double h_active_pixels, h_ideal_duty_cycle, h_blank_pixels, pixel_freq = 0; - double v_sync_plus_bp = 0, v_total_lines = 0, v_field_rate_est, v_frame_rate = 0; - const double h_pixels = (double) width; - const double v_lines = (double) height; - - enum { - left_margin_pixels = 0, - right_margin_pixels = 0, - top_margin_lines = 0, - bot_margin_lines = 0, - interlace = 0 - }; - - // Total number of active pixels in image and both margins - h_active_pixels = h_pixels + left_margin_pixels + right_margin_pixels; - - if (paramType == kCRTCParamPixelClock) - { - // Pixel clock provided in MHz - pixel_freq = (double) paramValue / 1000000; - - // Ideal horizontal period from the blanking duty cycle equation - h_period = ((kC - 100) + (Sqrt(((100 - kC) * (100 - kC)) + (0.4 * kM * - (h_active_pixels + right_margin_pixels + left_margin_pixels) / - pixel_freq)))) / 2.0 / kM * 1000; - } - else /* kCRTCParamRefreshRate */ - { - double v_field_rate_in = (double) paramValue; - - // Estimate the horizontal period - h_period_est = ((1 / v_field_rate_in) - kMinVSyncPlusBP / 1000000) / - (v_lines + (2 * top_margin_lines) + kMinFrontPorch + interlace) * - 1000000; - - // Number of lines in Vsync + back porch - v_sync_plus_bp = Round(kMinVSyncPlusBP / h_period_est); - - // Total number of lines in Vetical field period - v_total_lines = v_lines + top_margin_lines + bot_margin_lines + - v_sync_plus_bp + interlace + kMinFrontPorch; - - // Estimate the vertical field frequency - v_field_rate_est = 1 / h_period_est / v_total_lines * 1000000; - - // Find the actual horizontal period - h_period = h_period_est / (v_field_rate_in / v_field_rate_est); - - // Find the vertical frame rate (no interlace) - v_frame_rate = 1 / h_period / v_total_lines * 1000000; - } - - // Ideal blanking duty cycle from the blanking duty cycle equation - h_ideal_duty_cycle = kC - (kM * h_period / 1000); - - // Number of pixels in the blanking time to the nearest double character cell - h_blank_pixels = Round(h_active_pixels * h_ideal_duty_cycle / - (100 - h_ideal_duty_cycle) / (2 * kCellGranularity)) * - (2 * kCellGranularity); - - // Total number of horizontal pixels - h_total_pixels = h_active_pixels + h_blank_pixels; - - if (paramType == kCRTCParamPixelClock) - { - // Horizontal frequency - h_freq = pixel_freq / h_total_pixels * 1000; - - // Number of lines in V sync + back porch - v_sync_plus_bp = Round(kMinVSyncPlusBP * h_freq / 1000); - - // Total number of lines in vertical field period - v_total_lines = v_lines + top_margin_lines + bot_margin_lines + - interlace + v_sync_plus_bp + kMinFrontPorch; - - // Vertical frame frequency - v_frame_rate = Round(h_freq / v_total_lines * 1000); - } - else - { - // Find pixel clock frequency - pixel_freq = Round(h_total_pixels / h_period); - } - - h_sync_pixels = Round(h_total_pixels * kHSyncWidth / 100 / kCellGranularity) * - kCellGranularity; - - timing->HTotal = h_total_pixels; - timing->HSyncStart = h_active_pixels + (h_blank_pixels / 2) - h_sync_pixels; - timing->HSyncEnd = timing->HSyncStart + h_sync_pixels; - timing->VTotal = v_total_lines; - timing->VSyncStart = v_total_lines - v_sync_plus_bp; - timing->VSyncEnd = timing->VSyncStart + kVSyncLines; - timing->Flags = kCRTCNegativeHorizontalSync; - timing->PixelClock = pixel_freq * 1000000; - timing->RefreshRate = v_frame_rate * 100; - - return 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); -} - -int setVBEPalette(void *palette) -{ - bb.intno = 0x10; - bb.eax.rr = funcGetSetPaletteData; - bb.ebx.r.l = subfuncSet; - bb.ecx.rr = 256; - bb.edx.rr = 0; - bb.es = SEG(palette); - bb.edi.rr = OFF(palette); - bios(&bb); - return(bb.eax.r.h); -} - -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); -} - -int getVBECurrentMode(unsigned short *mode) -{ - bb.intno = 0x10; - bb.eax.rr = funcGetCurrentMode; - bios(&bb); - *mode = bb.ebx.rr; - return(bb.eax.r.h); -} - -int getVBEPixelClock(unsigned short mode, unsigned long * pixelClock) -{ - bb.intno = 0x10; - bb.eax.rr = funcGetSetPixelClock; - bb.ebx.r.l = 0; - bb.ecx.rx = *pixelClock; - bb.edx.rr = mode; - bios(&bb); - *pixelClock = bb.ecx.rx; - return(bb.eax.r.h); -} Index: branches/rewrite/i386/libsaio/vbe.h =================================================================== --- branches/rewrite/i386/libsaio/vbe.h (revision 1088) +++ branches/rewrite/i386/libsaio/vbe.h (revision 1089) @@ -1,286 +0,0 @@ -/* - * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 2.0 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * - * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -// Copyright 1997 by Apple Computer, Inc., all rights reserved. -/* Copyright 1996-1997 NeXT Software, Inc. - * - * vesa.h - mode info obtained via int10 - * - * Revision History - * ---------------- - * 30 Jul 1996 Doug Mitchell at NeXT - * Created. - */ - -#ifndef __LIBSAIO_VBE_H -#define __LIBSAIO_VBE_H - -#define MIN_VESA_VERSION 0x200 - -#define SEG(address) \ - ((unsigned short)(((unsigned long)address & 0xffff0000) >> 4)) - -#define OFF(address) \ - ((unsigned short)((unsigned long)address & 0x0000ffff)) - -#define VBEMakeUInt32(x) \ - (((unsigned long)x##_high << 24) | \ - ((unsigned long)x##_2 << 16) | \ - ((unsigned long)x##_1 << 8) | \ - (unsigned long)x##_low) - -#define VBEDecodeFP(t, fp) \ - ((t)(((fp ## _low) | ((fp ## _1 ) << 8)) + \ - (((fp ## _2) << 4) | ((fp ## _high ) << 12)))) - -/* - * Functions - */ -enum { - funcGetControllerInfo = 0x4F00, - funcGetModeInfo = 0x4F01, - funcSetMode = 0x4F02, - funcGetCurrentMode = 0x4F03, - funcSaveRestoreState = 0x4F04, - funcWindowControl = 0x4F05, - funcGetSetScanLineLength = 0x4F06, - funcGetSetDisplayStart = 0x4F07, - funcGetSetPaletteFormat = 0x4F08, - funcGetSetPaletteData = 0x4F09, - funcGetProtModeInterdace = 0x4F0A, - funcGetSetPixelClock = 0x4F0B -}; - -enum { - subfuncSet = 0x00, - subfuncGet = 0x01, - subfuncSetSecondary = 0x02, - subfuncGetSecondary = 0x03 -}; - -/* - * errors. - */ -enum { - errSuccess = 0, - errFuncFailed = 1, - errFuncNotSupported = 2, - errFuncInvalid = 3 -}; - -/* - * Per-controller info, returned in function 4f00. - */ -typedef struct { - unsigned char VESASignature[4]; - unsigned short VESAVersion; - /* - * Avoid packing problem... - */ - unsigned char OEMStringPtr_low; - unsigned char OEMStringPtr_1; - unsigned char OEMStringPtr_2; - unsigned char OEMStringPtr_high; - unsigned char Capabilities_low; - unsigned char Capabilities_1; - unsigned char Capabilities_2; - unsigned char Capabilities_high; - unsigned char VideoModePtr_low; - unsigned char VideoModePtr_1; - unsigned char VideoModePtr_2; - unsigned char VideoModePtr_high; - unsigned short TotalMemory; - unsigned char Reserved[236]; - unsigned char OEMData[256]; -} VBEInfoBlock; - -/* - * Capabilites - */ -enum { - capDACWidthIsSwitchableBit = (1 << 0), /* 1 = yes; 0 = no */ - capControllerIsNotVGACompatableBit = (1 << 1), /* 1 = no; 0 = yes */ - capOldRAMDAC = (1 << 2) /* 1 = yes; 0 = no */ -}; - -/* - * Per-mode info, returned in function 4f02. - */ -typedef struct { - unsigned short ModeAttributes; - unsigned char WinAAttributes; - unsigned char WinBAttributes; - unsigned short WinGranularity; - unsigned short WinSize; - unsigned short WinASegment; - unsigned short WinABegment; - void * WinFuncPtr; - unsigned short BytesPerScanline; - unsigned short XResolution; - unsigned short YResolution; - unsigned char XCharSize; - unsigned char YCharSize; - unsigned char NumberOfPlanes; - unsigned char BitsPerPixel; - unsigned char NumberOfBanks; - unsigned char MemoryModel; - unsigned char BankSize; - unsigned char NumberOfImagePages; - unsigned char Reserved; - unsigned char RedMaskSize; - unsigned char RedFieldPosition; - unsigned char GreenMaskSize; - unsigned char GreenFieldPosition; - unsigned char BlueMaskSize; - unsigned char BlueFieldPosition; - unsigned char RsvdMaskSize; - unsigned char RsvdFieldPosition; - unsigned char DirectColorModeInfo; - unsigned char PhysBasePtr_low; - unsigned char PhysBasePtr_1; - unsigned char PhysBasePtr_2; - unsigned char PhysBasePtr_high; - void * OffScreenMemOffset; - unsigned short OffScreenMemSize; - unsigned char Reserved1[206]; -} VBEModeInfoBlock; - -/* - * ModeAttributes bits - */ -enum { - maModeIsSupportedBit = (1 << 0), /* mode is supported */ - maExtendedInfoAvailableBit = (1 << 1), /* extended info available */ - maOutputFuncSupportedBit = (1 << 2), /* output functions supported */ - maColorModeBit = (1 << 3), /* 1 = color; 0 = mono */ - maGraphicsModeBit = (1 << 4), /* 1 = graphics; 0 = text */ - maModeIsNotVGACompatableBit = (1 << 5), /* 1 = not compat; 0 = compat */ - maVGAMemoryModeNotAvailBit = (1 << 6), /* 1 = not avail; 0 = avail */ - maLinearFrameBufferAvailBit = (1 << 7) /* 1 = avail; 0 = not avail */ -}; - -/* - * Modes - */ -enum { - mode640x400x256 = 0x100, - mode640x480x256 = 0x101, - mode800x600x16 = 0x102, - mode800x600x256 = 0x103, - mode1024x768x16 = 0x104, - mode1024x768x256 = 0x105, - mode1280x1024x16 = 0x106, - mode1280x1024x256 = 0x107, - mode80Cx60R = 0x108, - mode132Cx25R = 0x109, - mode132Cx43R = 0x10A, - mode132Cx50R = 0x10B, - mode132Cx60R = 0x10C, - mode320x200x555 = 0x10D, - mode320x200x565 = 0x10E, - mode320x200x888 = 0x10F, - mode640x480x555 = 0x110, - mode640x480x565 = 0x111, - mode640x480x888 = 0x112, - mode800x600x555 = 0x113, - mode800x600x565 = 0x114, - mode800x600x888 = 0x115, - mode1024x768x555 = 0x116, - mode1024x768x565 = 0x117, - mode1024x768x888 = 0x118, - mode1280x1024x555 = 0x119, - mode1280x1024x565 = 0x11A, - mode1280x1024x888 = 0x11B, - modeSpecial = 0x81FF, - modeEndOfList = 0xFFFF -}; - -/* - * Get/Set VBE Mode parameters - */ -enum { - kCustomRefreshRateBit = (1 << 11), - kLinearFrameBufferBit = (1 << 14), - kPreserveMemoryBit = (1 << 15) -}; - -/* - * CRTC information block passed to function 4F02 - * to override default refresh rate. - */ -#pragma pack(1) - -typedef struct { - unsigned short HTotal; - unsigned short HSyncStart; - unsigned short HSyncEnd; - unsigned short VTotal; - unsigned short VSyncStart; - unsigned short VSyncEnd; - unsigned char Flags; - unsigned long PixelClock; /* in Hz */ - unsigned short RefreshRate; /* units of 0.01 Hz */ - unsigned char Reserved[40]; -} VBECRTCInfoBlock; - -#pragma pack() - -/* - * Defined flags for 'Flags' field in VBECRTCInfoBlock. - */ -enum { - kCRTCDoubleScannedMode = (1 << 0), - kCRTCInterlacedMode = (1 << 1), - kCRTCNegativeHorizontalSync = (1 << 2), - kCRTCNegativeVerticalSync = (1 << 3) -}; - -/* - * The type of paramter passed to generateCRTCTimings(). - */ -enum { - kCRTCParamRefreshRate, - kCRTCParamPixelClock -}; - -/* - * Palette - */ -typedef unsigned long VBEPalette[256]; - -extern int getVBEInfo(void *vinfo_p); -extern int getVBEModeInfo(int mode, void *minfo_p); -extern int getVBEDACFormat(unsigned char *format); -extern int setVBEDACFormat(unsigned char format); -extern int setVBEPalette(void *palette); -extern int getVBEPalette(void *palette); -extern int setVBEMode(unsigned short mode, const VBECRTCInfoBlock *timing); -extern int getVBECurrentMode(unsigned short *mode); -extern int getVBEPixelClock(unsigned short mode, unsigned long *pixelClock); -extern int generateCRTCTiming(unsigned short width, - unsigned short height, - unsigned long paramValue, - int paramType, - VBECRTCInfoBlock * timing); - -#endif /* !__LIBSAIO_VBE_H */ Index: branches/rewrite/i386/libsaio/md5c.c =================================================================== --- branches/rewrite/i386/libsaio/md5c.c (revision 1088) +++ branches/rewrite/i386/libsaio/md5c.c (revision 1089) @@ -1,293 +0,0 @@ -/* - * MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm - * - * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - * rights reserved. - * - * License to copy and use this software is granted provided that it - * is identified as the "RSA Data Security, Inc. MD5 Message-Digest - * Algorithm" in all material mentioning or referencing this software - * or this function. - * - * License is also granted to make and use derivative works provided - * that such works are identified as "derived from the RSA Data - * Security, Inc. MD5 Message-Digest Algorithm" in all material - * mentioning or referencing the derived work. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - * - * $Id: md5c.c,v 1.1 2005/06/24 22:47:12 curtisg Exp $ - * - * This code is the same as the code published by RSA Inc. It has been - * edited for clarity and style only. - */ - -#include "libsaio.h" -#include - - -#define Encode memcpy -#define Decode memcpy - -static unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* F, G, H and I are basic MD5 functions. */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* ROTATE_LEFT rotates x left n bits. */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* - * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. - * Rotation is separate from addition to prevent recomputation. - */ -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (u_int32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -static void MD5Transform (u_int32_t state[4], const unsigned char block[64]); - -/* MD5 initialization. Begins an MD5 operation, writing a new context. */ - -void -MD5Init (context) - MD5_CTX *context; -{ - - context->count[0] = context->count[1] = 0; - - /* Load magic initialization constants. */ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; -} - -/* - * MD5 block update operation. Continues an MD5 message-digest - * operation, processing another message block, and updating the - * context. - */ - -void -MD5Update (context, input, inputLen) - MD5_CTX *context; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - const void *input; -#else - const unsigned char *input; -#endif - unsigned int inputLen; -{ - unsigned int i, index, partLen; - - /* Compute number of bytes mod 64 */ - index = (unsigned int)((context->count[0] >> 3) & 0x3F); - - /* Update number of bits */ - if ((context->count[0] += ((u_int32_t)inputLen << 3)) - < ((u_int32_t)inputLen << 3)) - context->count[1]++; - context->count[1] += ((u_int32_t)inputLen >> 29); - - partLen = 64 - index; - - /* Transform as many times as possible. */ - if (inputLen >= partLen) { - memcpy((void *)&context->buffer[index], (const void *)input, - partLen); - MD5Transform (context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform (context->state, &((const unsigned char *)input)[i]); - - index = 0; - } - else - i = 0; - - /* Buffer remaining input */ - memcpy ((void *)&context->buffer[index], (const void *)&((const unsigned char*)input)[i], - inputLen-i); -} - -/* - * MD5 padding. Adds padding followed by original length. - */ - -void -MD5Pad (context) - MD5_CTX *context; -{ - unsigned char bits[8]; - unsigned int index, padLen; - - /* Save number of bits */ - Encode (bits, context->count, 8); - - /* Pad out to 56 mod 64. */ - index = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - MD5Update (context, PADDING, padLen); - - /* Append length (before padding) */ - MD5Update (context, bits, 8); -} - -/* - * MD5 finalization. Ends an MD5 message-digest operation, writing the - * the message digest and zeroizing the context. - */ - -void -MD5Final (digest, context) - unsigned char digest[16]; - MD5_CTX *context; -{ - /* Do padding. */ - MD5Pad (context); - - /* Store state in digest */ - Encode (digest, context->state, 16); - - /* Zeroize sensitive information. */ - memset ((void *)context, 0, sizeof (*context)); -} - -/* MD5 basic transformation. Transforms state based on block. */ - -static void -MD5Transform (state, block) - u_int32_t state[4]; - const unsigned char block[64]; -{ - u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode (x, block, 64); - - /* Round 1 */ -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. */ - memset ((void *)x, 0, sizeof (x)); -} Index: branches/rewrite/i386/libsaio/Makefile =================================================================== --- branches/rewrite/i386/libsaio/Makefile (revision 1088) +++ branches/rewrite/i386/libsaio/Makefile (revision 1089) @@ -29,10 +29,8 @@ INC = -I. -I$(SYMROOT) -I$(LIBSADIR) -I$(BOOT2DIR) -I${SRCROOT}/i386/include SAIO_OBJS = table.o asm.o bios.o biosfn.o \ - cache.o \ misc.o \ - vbe.o \ - xml.o md5c.o \ + xml.o \ load.o \ console.o Index: branches/rewrite/i386/modules/Disk/include/GUIDPartition.hpp =================================================================== --- branches/rewrite/i386/modules/Disk/include/GUIDPartition.hpp (revision 1088) +++ branches/rewrite/i386/modules/Disk/include/GUIDPartition.hpp (revision 1089) @@ -20,4 +20,4 @@ private: }; -#endif /* FDISK_PARTITION_H */ +#endif /* GUID_PARTITION_H */