/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
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
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
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
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);
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,
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;
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)))
{
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;
} 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;
* @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>
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();
}
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 )))
{
regEntry->release();
}
}
-
+
return id;
}
enum {
kgestaltPwrBkEKDomKbd = 0xc3,
kgestaltPwrBkEKISOKbd = 0xc4,
- kgestaltPwrBkEKJISKbd = 0xc5
+ kgestaltPwrBkEKJISKbd = 0xc5,
+ kgestaltPwrBk99JISKbd = 0xc9
};
class AppleADBKeyboard : public IOHIKeyboard
UInt32 maxKeyCodes ( void );
const unsigned char * defaultKeymapOfLength (UInt32 * length );
UInt32 interfaceID ( void );
-UInt32 deviceType ( void );
bool doesKeyLock ( unsigned key);
unsigned getLEDStatus (void );
bool programmerKey;
public:
+UInt32 deviceType ( void );
IOADBDevice * adbDevice;
UInt16 turnLEDon; // used by setAlphaLockFeedback mechanism
UInt16 LEDStatus; //For ADB device TALK commands
#include <string.h>
+#define kAppleAudioVideoJackStateKey "AppleAudioVideoJackState"
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
class IOATINDRV : public IONDRVFramebuffer
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 );
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)
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)
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;
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,
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,
/*! @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.
*
* @APPLE_LICENSE_HEADER_END@
*/
+#ifndef IOADBDEVICE_H
+#define IOADBDEVICE_H
+
#include <IOKit/IOService.h>
#include <IOKit/adb/adb.h>
#include <IOKit/adb/IOADBBus.h>
void * busRef ( void );
};
+
+#endif
+
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 );
#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);
bool IOService::activityTickle ( unsigned long type, unsigned long stateNumber=0 )
{
+ AbsoluteTime uptime;
+
if ( type == kIOPMSuperclassPolicy1 ) {
if ( (priv->activityLock == NULL) ||
(pm_vars->theControllingDriver == NULL) ||
}
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;
//*********************************************************************************
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;
}
*/
const char * gIOKernelKmods =
"{
- 'com.apple.kernel' = '1.0.0b1';
- 'com.apple.kernel.bsd' = '1.0.0b1';
- 'com.apple.kernel.iokit' = '1.0.0b1';
- 'com.apple.kernel.libkern' = '1.0.0b1';
- 'com.apple.kernel.mach' = '1.0.0b1';
- 'com.apple.iokit.IOADBFamily' = '1.0.0b1';
- 'com.apple.iokit.IOCDStorageFamily' = '1.0.0b1';
- 'com.apple.iokit.IODVDStorageFamily' = '1.0.0b1';
- 'com.apple.iokit.IOGraphicsFamily' = '1.0.0b1';
- 'com.apple.iokit.IOHIDSystem' = '1.0.0b1';
- 'com.apple.iokit.IONDRVSupport' = '1.0.0b1';
- 'com.apple.iokit.IONetworkingFamily' = '1.0.0b1';
- 'com.apple.iokit.IOPCIFamily' = '1.0.0b1';
- 'com.apple.iokit.IOStorageFamily' = '1.0.0b1';
- 'com.apple.iokit.IOSystemManagementFamily' = '1.0.0b1';
+ 'com.apple.kernel' = '1.3.2';
+ 'com.apple.kernel.bsd' = '1.0.2';
+ 'com.apple.kernel.iokit' = '1.0.2';
+ 'com.apple.kernel.libkern' = '1.0.2';
+ 'com.apple.kernel.mach' = '1.0.2';
+ 'com.apple.iokit.IOADBFamily' = '1.0.2';
+ 'com.apple.iokit.IOCDStorageFamily' = '1.0.2';
+ 'com.apple.iokit.IODVDStorageFamily' = '1.0.2';
+ 'com.apple.iokit.IOGraphicsFamily' = '1.0.2';
+ 'com.apple.iokit.IOHIDSystem' = '1.0.2';
+ 'com.apple.iokit.IONDRVSupport' = '1.0.2';
+ 'com.apple.iokit.IONetworkingFamily' = '1.0.2';
+ 'com.apple.iokit.IOPCIFamily' = '1.0.2';
+ 'com.apple.iokit.IOStorageFamily' = '1.0.2';
+ 'com.apple.iokit.IOSystemManagementFamily' = '1.0.2';
}";
{
thread_t th = current_thread();
- return(!th->top_act || (th->state & TH_ABORT));
+ return(!th->top_act ||
+ ((th->state & TH_ABORT) && (th->interruptible)));
}
/*
wake_lock(thread);
while (thread->state & TH_SUSP) {
+ int wait_result;
+
thread->wake_active = TRUE;
assert_wait((event_t)&thread->wake_active, THREAD_ABORTSAFE);
wake_unlock(thread);
splx(s);
- thread_block((void (*)(void)) 0);
- if (current_thread()->wait_result != THREAD_AWAKENED)
+ wait_result = thread_block((void (*)(void)) 0);
+ if (wait_result != THREAD_AWAKENED)
return (FALSE);
s = splsched();
wake_lock(thread);
while (thread->state & (TH_RUN/*|TH_UNINT*/)) {
+ int wait_result;
+
if (thread->last_processor != PROCESSOR_NULL)
cause_ast_check(thread->last_processor);
wake_unlock(thread);
splx(s);
- thread_block((void (*)(void))0);
- if (current_thread()->wait_result != THREAD_AWAKENED)
- return (FALSE);
+ wait_result = thread_block((void (*)(void))0);
+ if (wait_result != THREAD_AWAKENED)
+ return FALSE;
s = splsched();
wake_lock(thread);
}
-
wake_unlock(thread);
splx(s);
-
- return (TRUE);
+ return TRUE;
}
{
thread_act_t thr_act, cur_thr_act;
task_t cur_task;
+ thread_t cur_thread;
+ boolean_t interrupt_save;
assert(task != kernel_task);
if (cur_task != task)
task_unlock(cur_task);
+ /*
+ * Make sure the current thread does not get aborted out of
+ * the waits inside these operations.
+ */
+ cur_thread = current_thread();
+ interrupt_save = cur_thread->interruptible;
+ cur_thread->interruptible = FALSE;
+
/*
* Indicate that we want all the threads to stop executing
* at user space by holding the task (we would have held
* clean up most of the thread resources. Then it will be
* handed over to the reaper, who will finally remove the
* thread from the task list and free the structures.
- *
- * We can't terminate the current activation yet, because
- * it has to wait for the others in an interruptible state.
- * We may also block interruptibly during the rest of the
- * cleanup. Wait until the very last to terminate ourself.
- *
- * But if we have virtual machine state, we need to clean
- * that up now, because it may be holding wirings the task's
- * map that would get stuck in the vm_map_remove() below.
*/
queue_iterate(&task->thr_acts, thr_act, thread_act_t, thr_acts) {
- if (thr_act != cur_thr_act)
thread_terminate_internal(thr_act);
- else
- act_virtual_machine_destroy(thr_act);
}
+
+ /*
+ * Clean up any virtual machine state/resources associated
+ * with the current activation because it may hold wiring
+ * and other references on resources we will be trying to
+ * release below.
+ */
+ if (cur_thr_act->task == task)
+ act_virtual_machine_destroy(cur_thr_act);
+
task_unlock(task);
/*
task->map->max_offset, VM_MAP_NO_FLAGS);
/*
- * Finally, mark ourself for termination and then
- * deallocate the task's reference to itself.
+ * We no longer need to guard against being aborted, so restore
+ * the previous interruptible state.
+ */
+ cur_thread->interruptible = interrupt_save;
+
+ /*
+ * Get rid of the task active reference on itself.
*/
- if (task == cur_task)
- thread_terminate(cur_thr_act);
task_deallocate(task);
return(KERN_SUCCESS);
* clean up most of the thread resources. Then it will be
* handed over to the reaper, who will finally remove the
* thread from the task list and free the structures.
- *
- * If the current thread has any virtual machine state
- * associated with it, clean that up now before we try
- * to clean up the task VM and port spaces.
*/
queue_iterate(&task->thr_acts, thr_act, thread_act_t,thr_acts) {
if (thr_act != cur_thr_act)
thread_terminate_internal(thr_act);
- else
- act_virtual_machine_destroy(thr_act);
}
task_release_locked(task);
}
+
+ /*
+ * If the current thread has any virtual machine state
+ * associated with it, we need to explicitly clean that
+ * up now (because we did not terminate the current act)
+ * before we try to clean up the task VM and port spaces.
+ */
+ act_virtual_machine_destroy(cur_thr_act);
+
task_unlock(task);
/*
*/
task_subsystem_destroy_all(task);
+#if 0
/*
* Destroy the IPC space, leaving just a reference for it.
*/
-#if 0
+ /*
+ * Lookupd will break if we enable this cleaning, because it
+ * uses a slimey trick that depends upon the portspace not
+ * being cleaned up across exec (it passes the lookupd server
+ * port to the child after a restart using knowledge of this
+ * bug in past implementations). We need to fix lookupd to
+ * keep from leaking ports across exec.
+ */
if (!task->kernel_loaded)
ipc_space_clean(task->itk_space);
#endif
task_t task;
struct ipc_port *iplock;
kern_return_t ret;
-#if NCPUS > 1
- boolean_t held;
-#endif /* NCPUS > 1 */
#if THREAD_SWAPPER
thread_swap_disable(thr_act);
return(KERN_TERMINATED);
}
+ act_disable_task_locked(thr_act);
+ ret = act_abort(thr_act,FALSE);
+
#if NCPUS > 1
/*
* Make sure this thread enters the kernel
thread_hold(thr_act);
act_unlock_thread(thr_act);
- if (!thread_stop_wait(thread)) {
+ if (thread_stop_wait(thread))
+ thread_unstop(thread);
+ else
ret = KERN_ABORTED;
- (void)act_lock_thread(thr_act);
- thread_release(thr_act);
- act_unlock_thread(thr_act);
- return (ret);
- }
- held = TRUE;
(void)act_lock_thread(thr_act);
- } else {
- held = FALSE;
+ thread_release(thr_act);
}
#endif /* NCPUS > 1 */
- assert(thr_act->active);
- act_disable_task_locked(thr_act);
- ret = act_abort(thr_act,FALSE);
act_unlock_thread(thr_act);
-
-#if NCPUS > 1
- if (held) {
- thread_unstop(thread);
- (void)act_lock_thread(thr_act);
- thread_release(thr_act);
- act_unlock_thread(thr_act);
- }
-#endif /* NCPUS > 1 */
return(ret);
}
thread_lock(thr_act->thread);
if (thr_act->thread->top_act == thr_act) {
thr_act->thread->state |= TH_ABORT;
- if (thr_act->thread->state & TH_ABORT)
- clear_wait_internal(thr_act->thread, THREAD_INTERRUPTED);
+ clear_wait_internal(thr_act->thread, THREAD_INTERRUPTED);
thread_unlock(thr_act->thread);
splx(spl);
install_special_handler(thr_act);
#endif /* MACH_ASSERT */
spl = splsched();
- if (thread)
- thread_lock(thread);
+ thread_lock(thread);
install_special_handler_locked(thr_act);
- act_set_apc(thr_act);
- if (thread)
- thread_unlock(thread);
+ thread_unlock(thread);
splx(spl);
}