Annotation of XNU/iokit/Drivers/platform/drvApplePMU/IOPMURTCController.cpp, revision 1.1.1.1

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 "IOPMURTCController.h"
                     28: #include "pmupriv.h"
                     29: 
                     30: //#define super IORTCController
                     31: //OSDefineMetaClassAndStructors(IOPMURTCController, IORTCController)
                     32: 
                     33: #define super IOService
                     34: OSDefineMetaClassAndStructors(IOPMURTCController, IOService)
                     35: 
                     36: 
                     37: // **********************************************************************************
                     38: // init
                     39: //
                     40: // **********************************************************************************
                     41: bool IOPMURTCController::init ( OSDictionary * regEntry, ApplePMU * driver )
                     42: {
                     43: PMUdriver = driver;
                     44: 
                     45: return super::init(regEntry);
                     46: }
                     47: 
                     48: 
                     49: // **********************************************************************************
                     50: // tickHandler
                     51: //
                     52: // **********************************************************************************
                     53: void tickHandler ( IOService * us, UInt32, UInt8 * )
                     54: {
                     55: ((IOPMURTCController *)us)->clientHandler(((IOPMURTCController *)us)->tickClient);
                     56: }
                     57: 
                     58: 
                     59: // **********************************************************************************
                     60: // registerForClockTicks
                     61: //
                     62: // The RTC driver is calling to tell us that it is prepared to receive clock
                     63: // ticks every second.  The parameter block tells who to call when we get one.
                     64: //
                     65: // **********************************************************************************
                     66: void IOPMURTCController::registerForClockTicks ( IOService * client, RTC_tick_handler handler )
                     67: {
                     68: clientHandler = handler;
                     69: tickClient = client;
                     70: PMUdriver->registerForClockInterrupts ( tickHandler, this );
                     71: }
                     72: 
                     73: 
                     74: // **********************************************************************************
                     75: // setRealTimeClock
                     76: //
                     77: // The RTC driver is calling to set the real time clock.  We translate this into
                     78: // a PMU command and enqueue it to our command queue.
                     79: //
                     80: // **********************************************************************************
                     81: IOReturn IOPMURTCController::setRealTimeClock ( UInt8 * newTime )
                     82: {
                     83: PMUrequest request;
                     84: 
                     85: if ( newTime == NULL ) {
                     86:         return kPMUParameterError;
                     87: }
                     88: 
                     89: request.sync = IOSyncer::create();
                     90: request.pmCommand = kPMUtimeWrite;
                     91: request.pmFlag = false;
                     92: request.pmSLength1 = 0;
                     93: request.pmSBuffer2 = newTime;
                     94: request.pmSLength2 = 4;
                     95: request.pmRBuffer = NULL;
                     96: 
                     97: PMUdriver->enqueueCommand(&request);
                     98: request.sync->wait();                  // wait till done
                     99: 
                    100: return kPMUNoError;
                    101: }
                    102: 
                    103: 
                    104: // **********************************************************************************
                    105: // getRealTimeClock
                    106: //
                    107: // The RTC driver is calling to read the real time clock.  We translate this into
                    108: // a PMU command and enqueue it to our command queue.
                    109: //
                    110: // The length parameter is ignored on entry.  On exit it is set to the length
                    111: // in bytes of the time read.
                    112: // **********************************************************************************
                    113: IOReturn IOPMURTCController::getRealTimeClock ( UInt8 * currentTime, IOByteCount * length )
                    114: {
                    115: PMUrequest  request;
                    116: 
                    117: if ( currentTime == NULL ) {
                    118:         return kPMUParameterError;
                    119: }
                    120: 
                    121: request.sync = IOSyncer::create();
                    122: request.pmCommand = kPMUtimeRead;
                    123: request.pmFlag = false;
                    124: request.pmSLength1 = 0;
                    125: request.pmSBuffer2 = NULL;
                    126: request.pmSLength2 = 0;
                    127: request.pmRBuffer = currentTime;
                    128: 
                    129: PMUdriver->enqueueCommand(&request);
                    130: request.sync->wait();                  // wait till done
                    131: 
                    132: *length = request.pmRLength;                           // set caller's length
                    133:     
                    134: return kPMUNoError;
                    135: }
                    136: 
                    137: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.