-/*
- * Nap control variables:
- */
-uint32_t forcenap = 0; /* Force nap (fn) boot-arg controls */
-
-/*
- * Do any initialization needed
- */
-void
-pmsInit(void)
-{
- static int initialized = 0;
-
- /*
- * Initialize some of the initial state to "uninitialized" until
- * it gets set with something more useful. This allows the KEXT
- * to determine if the initial value was actually set to something.
- */
- if (!initialized) {
- pmInitState.PState = -1;
- pmInitState.PLimit = -1;
- pmInitState.maxBusDelay = -1;
- initialized = 1;
- }
-
- if (pmDispatch != NULL && pmDispatch->pmsInit != NULL)
- (*pmDispatch->pmsInit)();
-}
-
-/*
- * Start the power management stepper on all processors
- *
- * All processors must be parked. This should be called when the hardware
- * is ready to step. Probably only at boot and after wake from sleep.
- *
- */
-void
-pmsStart(void)
-{
- if (pmDispatch != NULL && pmDispatch->pmsStart != NULL)
- (*pmDispatch->pmsStart)();
-}
-
-/*
- * Park the stepper execution. This will force the stepper on this
- * processor to abandon its current step and stop. No changes to the
- * hardware state is made and any previous step is lost.
- *
- * This is used as the initial state at startup and when the step table
- * is being changed.
- *
- */
-void
-pmsPark(void)
-{
- if (pmDispatch != NULL && pmDispatch->pmsPark != NULL)
- (*pmDispatch->pmsPark)();
-}
-
-/*
- * Control the Power Management Stepper.
- * Called from user state by the superuser.
- * Interrupts disabled.
- *
- * This interface is deprecated and is now a no-op.
- */
-kern_return_t
-pmsControl(__unused uint32_t request, __unused user_addr_t reqaddr,
- __unused uint32_t reqsize)
-{
- return(KERN_SUCCESS);
-}
-
-/*
- * Broadcast a change to all processors including ourselves.
- *
- * Interrupts disabled.
- */
-void
-pmsRun(uint32_t nstep)
-{
- if (pmDispatch != NULL && pmDispatch->pmsRun != NULL)
- (*pmDispatch->pmsRun)(nstep);
-}
-
-/*
- * Build the tables needed for the stepper. This includes both the step
- * definitions and the step control table.
- *
- * We most absolutely need to be parked before this happens because we're
- * going to change the table. We also have to be complte about checking
- * for errors. A copy is always made because we don't want to be crippled
- * by not being able to change the table or description formats.
- *
- * We pass in a table of external functions and the new stepper def uses
- * the corresponding indexes rather than actual function addresses. This
- * is done so that a proper table can be built with the control syscall.
- * It can't supply addresses, so the index has to do. We internalize the
- * table so our caller does not need to keep it. Note that passing in a 0
- * will use the current function table. Also note that entry 0 is reserved
- * and must be 0, we will check and fail the build.
- *
- * The platformData parameter is a 32-bit word of data that is passed unaltered
- * to the set function.
- *
- * The queryFunc parameter is the address of a function that will return the
- * current state of the platform. The format of the data returned is the same
- * as the platform specific portions of pmsSetCmd, i.e., pmsXClk, pmsVoltage,
- * and any part of pmsPowerID that is maintained by the platform hardware
- * (an example would be the values of the gpios that correspond to pmsPowerID).
- * The value should be constructed by querying hardware rather than returning
- * a value cached by software. One of the intents of this function is to help
- * recover lost or determine initial power states.
- *
- */
-kern_return_t
-pmsBuild(pmsDef *pd, uint32_t pdsize, pmsSetFunc_t *functab,
- uint32_t platformData, pmsQueryFunc_t queryFunc)
-{
- kern_return_t rc = 0;
-
- if (pmDispatch != NULL && pmDispatch->pmsBuild != NULL)
- rc = (*pmDispatch->pmsBuild)(pd, pdsize, functab,
- platformData, queryFunc);
-
- return(rc);
-}
-
-
-/*
- * Load a new ratio/VID table.
- *
- * Note that this interface is specific to the Intel SpeedStep implementation.
- * It is expected that this will only be called once to override the default
- * ratio/VID table when the platform starts.
- *
- * Normally, the table will need to be replaced at the same time that the
- * stepper program proper is replaced, as the PState indices from an old
- * program may no longer be valid. When replacing the default program this
- * should not be a problem as any new table will have at least two PState
- * entries and the default program only references P0 and P1.
- */
-kern_return_t
-pmsCPULoadVIDTable(uint16_t *tablep, int nstates)
-{
- if (pmDispatch != NULL && pmDispatch->pmsCPULoadVIDTable != NULL)
- return((*pmDispatch->pmsCPULoadVIDTable)(tablep, nstates));
- else {
- int i;
-
- if (nstates > MAX_PSTATES)
- return(KERN_FAILURE);
-
- for (i = 0; i < nstates; i += 1)
- pmInitState.VIDTable[i] = tablep[i];
- }
- return(KERN_SUCCESS);
-}
-
-/*
- * Set the (global) PState limit. CPUs will not be permitted to run at
- * a lower (more performant) PState than this.
- */
-kern_return_t
-pmsCPUSetPStateLimit(uint32_t limit)
-{
- if (pmDispatch != NULL && pmDispatch->pmsCPUSetPStateLimit != NULL)
- return((*pmDispatch->pmsCPUSetPStateLimit)(limit));
-
- pmInitState.PLimit = limit;
- return(KERN_SUCCESS);
-}