Skip to content

Commit

Permalink
xnu-124.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Jun 4, 2017
1 parent b09bd45 commit 587f919
Show file tree
Hide file tree
Showing 27 changed files with 214 additions and 103 deletions.
1 change: 1 addition & 0 deletions bsd/conf/version.variant
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
5 changes: 4 additions & 1 deletion bsd/hfs/hfs_vfsutils.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
* Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
Expand Down Expand Up @@ -2866,6 +2866,7 @@ void UnpackCommonAttributeBlock(struct attrlist *alist,
catInfo->nodeData.cnd_contentModDate = to_hfs_time((UInt32)((struct timespec *)attrbufptr)->tv_sec);
VTOH(vp)->h_meta->h_mtime = (UInt32)((struct timespec *)attrbufptr)->tv_sec;
++((struct timespec *)attrbufptr);
hp->h_nodeflags &= ~IN_UPDATE;
#if HFS_DIAGNOSTIC
a &= ~ATTR_CMN_MODTIME;
#endif
Expand All @@ -2874,6 +2875,7 @@ void UnpackCommonAttributeBlock(struct attrlist *alist,
catInfo->nodeData.cnd_attributeModDate = to_hfs_time((UInt32)((struct timespec *)attrbufptr)->tv_sec);
VTOH(vp)->h_meta->h_ctime = (UInt32)((struct timespec *)attrbufptr)->tv_sec;
++((struct timespec *)attrbufptr);
hp->h_nodeflags &= ~IN_CHANGE;
#if HFS_DIAGNOSTIC
a &= ~ATTR_CMN_CHGTIME;
#endif
Expand All @@ -2882,6 +2884,7 @@ void UnpackCommonAttributeBlock(struct attrlist *alist,
catInfo->nodeData.cnd_accessDate = to_hfs_time((UInt32)((struct timespec *)attrbufptr)->tv_sec);
VTOH(vp)->h_meta->h_atime = (UInt32)((struct timespec *)attrbufptr)->tv_sec;
++((struct timespec *)attrbufptr);
hp->h_nodeflags &= ~IN_ACCESS;
#if HFS_DIAGNOSTIC
a &= ~ATTR_CMN_ACCTIME;
#endif
Expand Down
2 changes: 1 addition & 1 deletion bsd/hfs/hfs_vnodeops.c
Original file line number Diff line number Diff line change
Expand Up @@ -3227,7 +3227,7 @@ struct vop_readdir_args /* {
goto Exit;
}

diroffset = uio->uio_offset;
diroffset = uio->uio_offset - sizeof(rootdots);

/* lock catalog b-tree */
retval = hfs_metafilelocking(VTOHFS(ap->a_vp), kHFSCatalogFileID, LK_SHARED, p);
Expand Down
3 changes: 1 addition & 2 deletions bsd/hfs/hfscommon/Catalog/Catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ GetDirEntrySize(BTreeIterator *bip, ExtendedVCB * vol)
cnp->ustr.length * sizeof(UniChar), ':', 0);
if (utf8chars > kdirentMaxNameBytes)
utf8chars = kdirentMaxNameBytes;
utf8chars++; /* account for NULL termination */
} else { /* hfs */
cnp = (CatalogName*) ckp->hfs.nodeName;
result = hfs_to_utf8(vol, cnp->pstr, kdirentMaxNameBytes + 1,
Expand All @@ -817,7 +816,7 @@ GetDirEntrySize(BTreeIterator *bip, ExtendedVCB * vol)
OSErr
PositionIterator(CatalogIterator *cip, UInt32 offset, BTreeIterator *bip, UInt16 *op)
{
#define CAT_START_OFFSET (2 * sizeof(struct hfsdotentry))
#define CAT_START_OFFSET 0
ExtendedVCB * vol;
FCB * fcb;
OSErr result = 0;
Expand Down
7 changes: 7 additions & 0 deletions bsd/kern/kern_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ sysctl_doproc(name, namelen, where, sizep)
break;
}
if (buflen >= sizeof(struct kinfo_proc)) {
bzero(&kproc, sizeof(struct kinfo_proc));
fill_proc(p, &kproc, doingzomb);
if (error = copyout((caddr_t)&kproc, &dp->kp_proc,
sizeof(struct kinfo_proc)))
Expand Down Expand Up @@ -882,6 +883,12 @@ fill_eproc(p, ep)
{
register struct tty *tp;

/*
* Skip zombie processes.
*/
if (p->p_stat == SZOMB)
return;

ep->e_paddr = p;
ep->e_sess = p->p_pgrp->pg_session;
ep->e_pcred = *p->p_cred;
Expand Down
5 changes: 1 addition & 4 deletions bsd/kern/sys_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,10 @@ selrecord(selector, sip)
} else {
sip->si_thread = my_thread;
splx(oldpri);
act_reference(current_act());
if (selthread) {
/* thread_deallocate(selthread); */
act_deallocate(getact_thread(selthread));
}
/* do I need act reference ??? */
/* thread_reference(sip->si_thread); */
act_reference(getact_thread(sip->si_thread));
}

return;
Expand Down
19 changes: 19 additions & 0 deletions iokit/Drivers/hidsystem/drvAppleADBDevices/AppleADBButtons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* @APPLE_LICENSE_HEADER_END@
*/
#include "AppleADBButtons.h"
#include "AppleADBKeyboard.h"
#include <IOKit/IOLib.h>
#include <IOKit/pwr_mgt/IOPM.h>
#include <IOKit/hidsystem/IOHIDTypes.h>
Expand Down Expand Up @@ -88,6 +89,24 @@ UInt32 AppleADBButtons::interfaceID()

UInt32 AppleADBButtons::deviceType()
{
//if initial id is 31 then this is a post-WallStreet PowerBook, so
//look for a AppleADBKeyboard driver and return the handler ID from it.
//Note though that the ADB keyboard driver may not exist.
if (_initial_handler_id == 31)
{
mach_timespec_t t;
AppleADBKeyboard *adbkeyboard;

t.tv_sec = 2;
t.tv_nsec = 0;
adbkeyboard = (AppleADBKeyboard *)waitForService(serviceMatching("AppleADBKeyboard"), &t);
if (adbkeyboard)
{
return adbkeyboard->deviceType();
}

}

return adbDevice->handlerID();
}

Expand Down
13 changes: 4 additions & 9 deletions iokit/Drivers/hidsystem/drvAppleADBDevices/AppleADBKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,18 @@ return NX_EVS_DEVICE_INTERFACE_ADB;
UInt32 AppleADBKeyboard::deviceType ( void )
{
UInt32 id; //We need handler ID to remap adjustable JIS keyboard

id = adbDevice->handlerID();
if (id == 18) //Adjustable JIS
{
kmapConvert[0x32] = 0x35; //tilde to ESC
}
IORegistryEntry *regEntry;
OSData * data = 0;
UInt32 *dataptr;

id = adbDevice->handlerID();
if (id == 18) //Adjustable JIS
{
kmapConvert[0x32] = 0x35; //tilde to ESC
}

if ((id == kgestaltPwrBkEKDomKbd) || (id == kgestaltPwrBkEKISOKbd) || (id == kgestaltPwrBkEKJISKbd))
if ((id == kgestaltPwrBkEKDomKbd) || (id == kgestaltPwrBkEKISOKbd) ||
(id == kgestaltPwrBkEKJISKbd) || (id == kgestaltPwrBk99JISKbd))
{
if( (regEntry = IORegistryEntry::fromPath( "/pci@f2000000/mac-io/via-pmu/adb/keyboard", gIODTPlane )))
{
Expand All @@ -122,7 +117,7 @@ UInt32 AppleADBKeyboard::deviceType ( void )
regEntry->release();
}
}

return id;
}

Expand Down
5 changes: 3 additions & 2 deletions iokit/Drivers/hidsystem/drvAppleADBDevices/AppleADBKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
enum {
kgestaltPwrBkEKDomKbd = 0xc3,
kgestaltPwrBkEKISOKbd = 0xc4,
kgestaltPwrBkEKJISKbd = 0xc5
kgestaltPwrBkEKJISKbd = 0xc5,
kgestaltPwrBk99JISKbd = 0xc9
};

class AppleADBKeyboard : public IOHIKeyboard
Expand All @@ -39,7 +40,6 @@ void setNumLockFeedback ( bool to );
UInt32 maxKeyCodes ( void );
const unsigned char * defaultKeymapOfLength (UInt32 * length );
UInt32 interfaceID ( void );
UInt32 deviceType ( void );
bool doesKeyLock ( unsigned key);
unsigned getLEDStatus (void );
bool programmerKey;
Expand All @@ -49,6 +49,7 @@ AbsoluteTime debuggerTime;

public:

UInt32 deviceType ( void );
IOADBDevice * adbDevice;
UInt16 turnLEDon; // used by setAlphaLockFeedback mechanism
UInt16 LEDStatus; //For ADB device TALK commands
Expand Down
27 changes: 27 additions & 0 deletions iokit/Families/IONDRVSupport/IONDRVFramebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

#include <string.h>

#define kAppleAudioVideoJackStateKey "AppleAudioVideoJackState"

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

class IOATINDRV : public IONDRVFramebuffer
Expand Down Expand Up @@ -242,6 +244,12 @@ IOReturn IONDRVFramebuffer::enableController( void )

if( kIOReturnSuccess == err) do {

// find out about onboard audio/video jack state
// OSObject * notify =
addNotification( gIOPublishNotification,
resourceMatching(kAppleAudioVideoJackStateKey),
_videoJackStateChangeHandler, this, 0 );

ignore_zero_fault( true );
err = checkDriver();
ignore_zero_fault( false );
Expand Down Expand Up @@ -273,6 +281,25 @@ IOReturn IONDRVFramebuffer::enableController( void )
return( err);
}

bool IONDRVFramebuffer::_videoJackStateChangeHandler( void * target, void * ref,
IOService * resourceService )
{
IONDRVFramebuffer * self = (IONDRVFramebuffer *) target;
IOReturn err;
UInt32 jackData;

OSObject * jackValue = resourceService->getProperty(kAppleAudioVideoJackStateKey);
if( !jackValue)
return( true );

jackData = (jackValue == kOSBooleanTrue);

self->nub->setProperty( kAppleAudioVideoJackStateKey, &jackData, sizeof(jackData) );
resourceService->removeProperty(kAppleAudioVideoJackStateKey);

return( true );
}

IODeviceMemory * IONDRVFramebuffer::getVRAMRange( void )
{
if( vramMemory)
Expand Down
7 changes: 6 additions & 1 deletion iokit/Families/IONDRVSupport/IONDRVLibraries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ _eRegistryCStrEntryLookup( const RegEntryID * parentEntry,
char * buf;
char * cvtPath;
char c;
#define kDTRoot "Devices:device-tree:"
#define kDTRoot "Devices:device-tree:"
#define kMacIORoot "Devices:device-tree:pci:mac-io:"

if( parentEntry) {
REG_ENTRY_TO_OBJ( parentEntry, regEntry)
Expand All @@ -669,6 +670,10 @@ _eRegistryCStrEntryLookup( const RegEntryID * parentEntry,
cvtPath = buf;
if( ':' == path[0])
path++;
else if( 0 == strncmp( path, kMacIORoot, strlen( kMacIORoot ))) {
path += strlen( kMacIORoot ) - 7;
regEntry = 0;
}
else if( 0 == strncmp( path, kDTRoot, strlen( kDTRoot ))) {
path += strlen( kDTRoot ) - 1;
regEntry = 0;
Expand Down
4 changes: 2 additions & 2 deletions iokit/Families/IOStorage/IOBlockStorageDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ IOByteCount IODeblocker::readBytes( IOByteCount offset,

for ( ; index < _chunksCount && withLength; index++)
{
IOByteCount copy = min(_chunks[index].length, withLength);
IOByteCount copy = min(_chunks[index].length - offset, withLength);
IOByteCount copied = _chunks[index].buffer->readBytes(
/* offset */ offset + _chunks[index].offset,
/* bytes */ bytes,
Expand Down Expand Up @@ -1798,7 +1798,7 @@ IOByteCount IODeblocker::writeBytes( IOByteCount offset,

for ( ; index < _chunksCount && withLength; index++)
{
IOByteCount copy = min(_chunks[index].length, withLength);
IOByteCount copy = min(_chunks[index].length - offset, withLength);
IOByteCount copied = _chunks[index].buffer->writeBytes(
/* offset */ offset + _chunks[index].offset,
/* bytes */ bytes,
Expand Down
3 changes: 3 additions & 0 deletions iokit/IOKit/IOServicePM.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class IOPMpriv : public OSObject
/*! @field device_active true: there has been device activity since last idle timer expiration */
bool device_active;

/*! @field device_active_timestamp time in ticks of last activity */
AbsoluteTime device_active_timestamp;

/*! @field driverDesire
This is the power state desired by our controlling driver. It is initialized to myCurrentState and is changed
when the controlling driver calls changePowerStateTo. A change in driverDesire may cause a change in ourDesiredPowerState.
Expand Down
6 changes: 6 additions & 0 deletions iokit/IOKit/adb/IOADBDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef IOADBDEVICE_H
#define IOADBDEVICE_H

#include <IOKit/IOService.h>
#include <IOKit/adb/adb.h>
#include <IOKit/adb/IOADBBus.h>
Expand Down Expand Up @@ -53,3 +56,6 @@ IOReturn setHandlerID ( UInt8 handlerID );
void * busRef ( void );

};

#endif

2 changes: 2 additions & 0 deletions iokit/IOKit/ndrvsupport/IONDRVFramebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class IONDRVFramebuffer : public IOFramebuffer
static const IOTVector * _undefinedSymbolHandler( void * self,
const char * libraryName, const char * symbolName );
void displayI2CPower( bool enable );
static bool _videoJackStateChangeHandler( void * target, void * ref,
IOService * resourceService );

public:
virtual IOReturn doControl( UInt32 code, void * params );
Expand Down
40 changes: 39 additions & 1 deletion iokit/Kernel/IOServicePM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "IOKit/pwr_mgt/IOPMchangeNoteList.h"
#include "IOKit/pwr_mgt/IOPMlog.h"
#include "IOKit/pwr_mgt/IOPowerConnection.h"
#include <kern/clock.h>

static void ack_timer_expired(thread_call_param_t);
static void settle_timer_expired(thread_call_param_t);
Expand Down Expand Up @@ -1188,6 +1189,8 @@ unsigned long IOService::currentPowerConsumption ( void )

bool IOService::activityTickle ( unsigned long type, unsigned long stateNumber=0 )
{
AbsoluteTime uptime;

if ( type == kIOPMSuperclassPolicy1 ) {
if ( (priv->activityLock == NULL) ||
(pm_vars->theControllingDriver == NULL) ||
Expand All @@ -1196,6 +1199,10 @@ bool IOService::activityTickle ( unsigned long type, unsigned long stateNumber=0
}
IOTakeLock(priv->activityLock);
priv->device_active = true;

clock_get_uptime(&uptime);
priv->device_active_timestamp = uptime;

if ( pm_vars->myCurrentState >= stateNumber) {
IOUnlock(priv->activityLock);
return true;
Expand Down Expand Up @@ -1285,7 +1292,38 @@ IOReturn IOService::setIdleTimerPeriod ( unsigned long period )
//*********************************************************************************
void IOService::start_PM_idle_timer ( void )
{
priv->timerEventSrc->setTimeout(priv->idle_timer_period, NSEC_PER_SEC);
AbsoluteTime uptime;
AbsoluteTime delta;
UInt64 delta_ns;
UInt64 delta_secs;
UInt64 delay_secs;

IOLockLock(priv->activityLock);

clock_get_uptime(&uptime);

/* Calculate time difference using funky macro from clock.h.
*/
delta = uptime;
SUB_ABSOLUTETIME(&delta, &(priv->device_active_timestamp));

/* Figure it in seconds.
*/
absolutetime_to_nanoseconds(delta, &delta_ns);
delta_secs = delta_ns / NSEC_PER_SEC;

/* Be paranoid about delta somehow exceeding timer period.
*/
if (delta_secs < priv->idle_timer_period ) {
delay_secs = priv->idle_timer_period - delta_secs;
} else {
delay_secs = priv->idle_timer_period;
}

priv->timerEventSrc->setTimeout(delay_secs, NSEC_PER_SEC);

IOLockUnlock(priv->activityLock);
return;
}


Expand Down
Loading

0 comments on commit 587f919

Please sign in to comment.