|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * 1 Dec 1998 suurballe Created. ! 24: */ ! 25: ! 26: #include <IOKit/IOSyncer.h> ! 27: #include "IOPMUNVRAMController.h" ! 28: #include "pmupriv.h" ! 29: ! 30: #define super IONVRAMController ! 31: OSDefineMetaClassAndStructors(IOPMUNVRAMController, IONVRAMController) ! 32: ! 33: ! 34: // ********************************************************************************** ! 35: // init ! 36: // ! 37: // ********************************************************************************** ! 38: bool IOPMUNVRAMController::init ( OSDictionary * properties, ApplePMU * driver ) ! 39: { ! 40: PMUdriver = driver; ! 41: ! 42: return super::init(properties); ! 43: } ! 44: ! 45: ! 46: ! 47: // ********************************************************************************** ! 48: // openNVRAM ! 49: // ! 50: // ! 51: // ********************************************************************************** ! 52: IOReturn IOPMUNVRAMController::openNVRAM ( void ) ! 53: { ! 54: return kPMUNoError; ! 55: } ! 56: ! 57: ! 58: // ********************************************************************************** ! 59: // readNVRAM ! 60: // ! 61: // The NVRAM driver is calling to read part of the NVRAM. We translate this into ! 62: // single-byte PMU commands and enqueue them to its command queue. ! 63: // ! 64: // ********************************************************************************** ! 65: IOReturn IOPMUNVRAMController::readNVRAM ( UInt32 Offset, IOByteCount * Length, UInt8 * Buffer ) ! 66: { ! 67: PMUrequest request; ! 68: IOByteCount i; ! 69: UInt8 * client_buffer = Buffer; ! 70: UInt32 our_offset = Offset; ! 71: ! 72: if ( (Buffer == NULL) || ! 73: (*Length == 0) || ! 74: (*Length > 8192) || ! 75: (Offset > 8192) || ! 76: ((*Length + Offset) > 8192) ) { ! 77: return kPMUParameterError; ! 78: } ! 79: ! 80: for ( i = 0; i < *Length ; i++ ) { ! 81: request.sync = IOSyncer::create(); ! 82: request.pmCommand = kPMUNVRAMRead; ! 83: request.pmFlag = false; ! 84: request.pmSLength1 = 2; ! 85: request.pmSBuffer2 = NULL; ! 86: request.pmSLength2 = 0; ! 87: request.pmRBuffer = client_buffer++; ! 88: request.pmSBuffer1[0] = our_offset >> 8; ! 89: request.pmSBuffer1[1] = our_offset++; ! 90: ! 91: PMUdriver->enqueueCommand(&request); ! 92: request.sync->wait(); // wait till done ! 93: } ! 94: ! 95: return kPMUNoError; ! 96: } ! 97: ! 98: ! 99: // ********************************************************************************** ! 100: // writeNVRAM ! 101: // ! 102: // The NVRAM driver is calling to write part of the NVRAM. We translate this into ! 103: // single-byte PMU commands and enqueue them to our command queue. ! 104: // ! 105: // ********************************************************************************** ! 106: IOReturn IOPMUNVRAMController::writeNVRAM ( UInt32 Offset, IOByteCount * Length, UInt8 * Buffer ) ! 107: { ! 108: PMUrequest request; ! 109: IOByteCount i; ! 110: UInt32 our_offset = Offset; ! 111: UInt8 * client_buffer = Buffer; ! 112: ! 113: if ( (Buffer == NULL) || ! 114: (*Length == 0) || ! 115: (*Length > 8192) || ! 116: (Offset > 8192) || ! 117: ((*Length + Offset) > 8192) ) { ! 118: return kPMUParameterError; ! 119: } ! 120: ! 121: for ( i = 0; i < *Length ; i++ ) { ! 122: request.sync = IOSyncer::create(); ! 123: request.pmCommand = kPMUNVRAMWrite; ! 124: request.pmFlag = false; ! 125: request.pmSLength1 = 3; ! 126: request.pmSBuffer2 = NULL; ! 127: request.pmSLength2 = 0; ! 128: request.pmRBuffer = NULL; ! 129: request.pmSBuffer1[0] = our_offset >> 8; ! 130: request.pmSBuffer1[1] = our_offset++; ! 131: request.pmSBuffer1[2] = *client_buffer++; ! 132: ! 133: PMUdriver->enqueueCommand(&request); ! 134: request.sync->wait(); // wait till done ! 135: } ! 136: ! 137: return kPMUNoError; ! 138: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.