]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ppc/PseudoKernel.c
xnu-517.7.21.tar.gz
[apple/xnu.git] / osfmk / ppc / PseudoKernel.c
index ce31867cfbd6717433b8c96cc916203fe4b41222..de30417ac1bf6bccfb26a0256c033ccd4fabe2e4 100644 (file)
@@ -69,10 +69,10 @@ kern_return_t syscall_notify_interrupt ( void ) {
 
        task_lock(task);                                                /* Lock our task */
        
-       fact = (thread_act_t)task->thr_acts.next;               /* Get the first activation on task */
+       fact = (thread_act_t)task->threads.next;                /* Get the first activation on task */
        act = 0;                                                                                /* Pretend we didn't find it yet */
        
-       for(i = 0; i < task->thr_act_count; i++) {              /* Scan the whole list */
+       for(i = 0; i < task->thread_count; i++) {               /* Scan the whole list */
                if(fact->mact.bbDescAddr) {                                     /* Is this a Blue thread? */
                        bttd = (BTTD_t *)(fact->mact.bbDescAddr & -PAGE_SIZE);
                        if(bttd->InterruptVector) {                             /* Is this the Blue interrupt thread? */
@@ -80,7 +80,7 @@ kern_return_t syscall_notify_interrupt ( void ) {
                                break;                                                          /* Found it, Bail the loop... */
                        }
                }
-               fact = (thread_act_t)fact->thr_acts.next;       /* Go to the next one */
+               fact = (thread_act_t)fact->task_threads.next;   /* Go to the next one */
        }
 
        if(!act) {                                                              /* Couldn't find a bluebox */
@@ -167,11 +167,11 @@ void bbSetRupt(ReturnHandler *rh, thread_act_t act) {
                        bttd->InterruptControlWord = (bttd->InterruptControlWord & ~kInterruptStateMask) | 
                                (kInPseudoKernel << kInterruptStateShift);
                                
-                       bttd->exceptionInfo.srr0 = sv->save_srr0;               /* Save the current PC */
-                       sv->save_srr0 = bttd->InterruptVector;                  /* Set the new PC */
-                       bttd->exceptionInfo.sprg1 = sv->save_r1;                /* Save the original R1 */
-                       sv->save_r1 = bttd->exceptionInfo.sprg0;                /* Set the new R1 */
-                       bttd->exceptionInfo.srr1 = sv->save_srr1;               /* Save the original MSR */
+                       bttd->exceptionInfo.srr0 = (unsigned int)sv->save_srr0;         /* Save the current PC */
+                       sv->save_srr0 = (uint64_t)act->mact.bbInterrupt;        /* Set the new PC */
+                       bttd->exceptionInfo.sprg1 = (unsigned int)sv->save_r1;          /* Save the original R1 */
+                       sv->save_r1 = (uint64_t)bttd->exceptionInfo.sprg0;      /* Set the new R1 */
+                       bttd->exceptionInfo.srr1 = (unsigned int)sv->save_srr1;         /* Save the original MSR */
                        sv->save_srr1 &= ~(MASK(MSR_BE)|MASK(MSR_SE));  /* Clear SE|BE bits in MSR */
                        act->mact.specFlags &= ~bbNoMachSC;                             /* reactivate Mach SCs */ 
                        disable_preemption();                                                   /* Don't move us around */
@@ -212,8 +212,10 @@ kern_return_t enable_bluebox(
         ) {
        
        thread_t                th;
-       vm_offset_t             kerndescaddr, physdescaddr, origdescoffset;
+       vm_offset_t             kerndescaddr, origdescoffset;
        kern_return_t   ret;
+       ppnum_t                 physdescpage;
+       BTTD_t                  *bttd;
        
        th = current_thread();                                                                  /* Get our thread */                                    
 
@@ -239,8 +241,8 @@ kern_return_t enable_bluebox(
                return KERN_FAILURE;    
        }
                
-       physdescaddr =                                                                                  /* Get the physical address of the page */
-               pmap_extract(th->top_act->map->pmap, (vm_offset_t) Desc_TableStart);
+       physdescpage =                                                                                  /* Get the physical page number of the page */
+               pmap_find_phys(th->top_act->map->pmap, (addr64_t)Desc_TableStart);
 
        ret =  kmem_alloc_pageable(kernel_map, &kerndescaddr, PAGE_SIZE);       /* Find a virtual address to use */
        if(ret != KERN_SUCCESS) {                                                               /* Could we get an address? */
@@ -252,19 +254,25 @@ kern_return_t enable_bluebox(
        }
        
        (void) pmap_enter(kernel_pmap,                                                  /* Map this into the kernel */
-               kerndescaddr, physdescaddr, VM_PROT_READ|VM_PROT_WRITE, 
+               kerndescaddr, physdescpage, VM_PROT_READ|VM_PROT_WRITE, 
                VM_WIMG_USE_DEFAULT, TRUE);
        
+       bttd = (BTTD_t *)kerndescaddr;                                                  /* Get the address in a convienient spot */ 
+       
        th->top_act->mact.bbDescAddr = (unsigned int)kerndescaddr+origdescoffset;       /* Set kernel address of the table */
        th->top_act->mact.bbUserDA = (unsigned int)Desc_TableStart;     /* Set user address of the table */
        th->top_act->mact.bbTableStart = (unsigned int)TWI_TableStart;  /* Set address of the trap table */
        th->top_act->mact.bbTaskID = (unsigned int)taskID;              /* Assign opaque task ID */
        th->top_act->mact.bbTaskEnv = 0;                                                /* Clean task environment data */
        th->top_act->mact.emPendRupts = 0;                                              /* Clean pending 'rupt count */
+       th->top_act->mact.bbTrap = bttd->TrapVector;                    /* Remember trap vector */
+       th->top_act->mact.bbSysCall = bttd->SysCallVector;              /* Remember syscall vector */
+       th->top_act->mact.bbInterrupt = bttd->InterruptVector;  /* Remember interrupt vector */
+       th->top_act->mact.bbPending = bttd->PendingIntVector;   /* Remember pending vector */
        th->top_act->mact.specFlags &= ~(bbNoMachSC | bbPreemptive);    /* Make sure mach SCs are enabled and we are not marked preemptive */
        th->top_act->mact.specFlags |= bbThread;                                /* Set that we are Classic thread */
                
-       if(!(((BTTD_t *)kerndescaddr)->InterruptVector)) {              /* See if this is a preemptive (MP) BlueBox thread */
+       if(!(bttd->InterruptVector)) {                                                  /* See if this is a preemptive (MP) BlueBox thread */
                th->top_act->mact.specFlags |= bbPreemptive;            /* Yes, remember it */
        }
                
@@ -368,17 +376,17 @@ int bb_settaskenv( struct savearea *save )
        task = current_task();                                                  /* Figure out who our task is */
 
        task_lock(task);                                                                /* Lock our task */
-       fact = (thread_act_t)task->thr_acts.next;               /* Get the first activation on task */
+       fact = (thread_act_t)task->threads.next;                /* Get the first activation on task */
        act = 0;                                                                                /* Pretend we didn't find it yet */
        
-       for(i = 0; i < task->thr_act_count; i++) {              /* Scan the whole list */
+       for(i = 0; i < task->thread_count; i++) {               /* Scan the whole list */
                if(fact->mact.bbDescAddr) {                                     /* Is this a Blue thread? */
                        if ( fact->mact.bbTaskID == save->save_r3 ) {   /* Is this the task we are looking for? */
                                act = fact;                                                     /* Yeah... */
                                break;                                                          /* Found it, Bail the loop... */
                        }
                }
-               fact = (thread_act_t)fact->thr_acts.next;       /* Go to the next one */
+               fact = (thread_act_t)fact->task_threads.next;   /* Go to the next one */
        }
 
        if ( !act || !act->active) {
@@ -392,7 +400,7 @@ int bb_settaskenv( struct savearea *save )
        act->mact.bbTaskEnv = save->save_r4;
        if(act == current_act()) {                                              /* Are we setting our own? */
                disable_preemption();                                           /* Don't move us around */
-               per_proc_info[cpu_number()].spcFlags = act->mact.specFlags;     /* Copy the flags */
+               per_proc_info[cpu_number()].ppbbTaskEnv = act->mact.bbTaskEnv;  /* Remember the environment */
                enable_preemption();                                            /* Ok to move us around */
        }