$OpenBSD: patch-cpu_tasking_cc,v 1.1 2001/02/02 16:59:10 todd Exp $
--- cpu/tasking.cc.orig	Sat Mar 25 21:39:09 2000
+++ cpu/tasking.cc	Tue Oct 31 12:28:32 2000
@@ -147,7 +147,7 @@ BX_CPU_C::task_switch(bx_selector_t *tss
   unsigned exception_no;
   Bit16u error_code;
 
-//fprintf(stderr, "TASKING: ENTER\n");
+//bio->printf("TASKING: ENTER\n");
 
   invalidate_prefetch_q();
 
@@ -198,7 +198,7 @@ BX_CPU_C::task_switch(bx_selector_t *tss
 
   // Task State Seg must be present, else #NP(TSS selector)
   if (tss_descriptor->p==0) {
-    bx_printf("task_switch: TSS.p == 0\n");
+    bio->printf("task_switch: TSS.p == 0\n");
     exception(BX_NP_EXCEPTION, tss_selector->value & 0xfffc, 0);
     }
 
@@ -206,7 +206,7 @@ BX_CPU_C::task_switch(bx_selector_t *tss
   if (tss_selector->ti ||
       tss_descriptor->valid==0 ||
       new_TSS_limit < new_TSS_max) {
-    bx_panic("task_switch(): TR not valid\n");
+    bio->panic("task_switch(): TR not valid\n");
     exception(BX_TS_EXCEPTION, tss_selector->value & 0xfffc, 0);
     }
 
@@ -293,7 +293,7 @@ BX_CPU_C::task_switch(bx_selector_t *tss
 
 #if 0
 if (ss_descriptor.u.segment.d_b && (tss_descriptor->type<9)) {
-  fprintf(stderr, "++++++++++++++++++++++++++\n");
+  bio->printf("++++++++++++++++++++++++++\n");
   BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.valid = 0;
   exception(BX_SS_EXCEPTION, raw_ss_selector & 0xfffc, 0);
   //exception(BX_TS_EXCEPTION, tss_selector->value & 0xfffc, 0);
@@ -510,7 +510,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
   // LDTR
   if (ldt_selector.ti) {
     // LDT selector must be in GDT
-    bx_printf("task_switch: bad LDT selector TI=1\n");
+    bio->printf("task_switch: bad LDT selector TI=1\n");
     exception_no = BX_TS_EXCEPTION;
     error_code   = raw_ldt_selector & 0xfffc;
     goto post_exception;
@@ -521,7 +521,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     Boolean good;
     good = fetch_raw_descriptor2(&ldt_selector, &dword1, &dword2);
     if (!good) {
-      bx_printf("task_switch: bad LDT fetch\n");
+      bio->printf("task_switch: bad LDT fetch\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ldt_selector & 0xfffc;
       goto post_exception;
@@ -534,7 +534,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
         ldt_descriptor.type!=2 ||
         ldt_descriptor.segment ||
         ldt_descriptor.u.ldt.limit<7) {
-      bx_printf("task_switch: bad LDT segment\n");
+      bio->printf("task_switch: bad LDT segment\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ldt_selector & 0xfffc;
       goto post_exception;
@@ -569,7 +569,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     Boolean good;
     good = fetch_raw_descriptor2(&cs_selector, &dword1, &dword2);
     if (!good) {
-      bx_printf("task_switch: bad CS fetch\n");
+      bio->printf("task_switch: bad CS fetch\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_cs_selector & 0xfffc;
       goto post_exception;
@@ -580,7 +580,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     // CS descriptor AR byte must indicate code segment else #TS(CS)
     if (cs_descriptor.valid==0 || cs_descriptor.segment==0 ||
         cs_descriptor.u.segment.executable==0) {
-      bx_panic("task_switch: CS not valid executable seg\n");
+      bio->panic("task_switch: CS not valid executable seg\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_cs_selector & 0xfffc;
       goto post_exception;
@@ -588,7 +588,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     // if non-conforming then DPL must equal selector RPL else #TS(CS)
     else if (cs_descriptor.u.segment.c_ed==0 &&
         cs_descriptor.dpl!=cs_selector.rpl) {
-      bx_printf("task_switch: non-conforming: CS.dpl!=CS.RPL\n");
+      bio->printf("task_switch: non-conforming: CS.dpl!=CS.RPL\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_cs_selector & 0xfffc;
       goto post_exception;
@@ -596,14 +596,14 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     // if conforming then DPL must be <= selector RPL else #TS(CS)
     else if (cs_descriptor.u.segment.c_ed &&
         cs_descriptor.dpl>cs_selector.rpl) {
-      bx_printf("task_switch: conforming: CS.dpl>RPL\n");
+      bio->printf("task_switch: conforming: CS.dpl>RPL\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_cs_selector & 0xfffc;
       goto post_exception;
       }
     // Code segment is present in memory, else #NP(new code segment)
     else if (cs_descriptor.p==0) {
-      bx_panic("task_switch: CS.p==0\n");
+      bio->panic("task_switch: CS.p==0\n");
       exception_no = BX_NP_EXCEPTION;
       error_code   = raw_cs_selector & 0xfffc;
       goto post_exception;
@@ -613,7 +613,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     }
   else {
     // If new cs selector is null #TS(CS)
-    bx_panic("task_switch: CS NULL\n");
+    bio->panic("task_switch: CS NULL\n");
     exception_no = BX_TS_EXCEPTION;
     error_code   = raw_cs_selector & 0xfffc;
     goto post_exception;
@@ -625,7 +625,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     Boolean good;
     good = fetch_raw_descriptor2(&ss_selector, &dword1, &dword2);
     if (!good) {
-      bx_printf("task_switch: bad SS fetch\n");
+      bio->printf("task_switch: bad SS fetch\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ss_selector & 0xfffc;
       goto post_exception;
@@ -639,7 +639,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
         ss_descriptor.segment==0 ||
         ss_descriptor.u.segment.executable ||
         ss_descriptor.u.segment.r_w==0) {
-      bx_printf("task_switch: SS not valid\n");
+      bio->printf("task_switch: SS not valid\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ss_selector & 0xfffc;
       goto post_exception;
@@ -649,7 +649,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     // Stack segment is present in memory, else #SF(new stack segment)
     //
     else if (ss_descriptor.p==0) {
-      bx_panic("task_switch: SS not present\n");
+      bio->panic("task_switch: SS not present\n");
       exception_no = BX_SS_EXCEPTION;
       error_code   = raw_ss_selector & 0xfffc;
       goto post_exception;
@@ -657,7 +657,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
 
     // Stack segment DPL matches CS.RPL, else #TS(new stack segment)
     else if (ss_descriptor.dpl != cs_selector.rpl) {
-      bx_panic("task_switch: SS.rpl != CS.RPL\n");
+      bio->panic("task_switch: SS.rpl != CS.RPL\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ss_selector & 0xfffc;
       goto post_exception;
@@ -665,7 +665,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
 
     // Stack segment DPL matches selector RPL, else #TS(new stack segment)
     else if (ss_descriptor.dpl != ss_selector.rpl) {
-      bx_panic("task_switch: SS.dpl != SS.rpl\n");
+      bio->panic("task_switch: SS.dpl != SS.rpl\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ss_selector & 0xfffc;
       goto post_exception;
@@ -674,7 +674,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
 #if 0
     // +++
     else if (ss_descriptor.u.segment.d_b && (tss_descriptor->type<9)) {
-      fprintf(stderr, "++++++++++++++++++++++++++\n");
+      bio->printf("++++++++++++++++++++++++++\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ss_selector & 0xfffc;
       goto post_exception;
@@ -685,7 +685,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     }
   else {
     // SS selector is valid, else #TS(new stack segment)
-    bx_panic("task_switch: SS NULL\n");
+    bio->panic("task_switch: SS NULL\n");
     exception_no = BX_TS_EXCEPTION;
     error_code   = raw_ss_selector & 0xfffc;
     goto post_exception;
@@ -708,7 +708,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     Boolean good;
     good = fetch_raw_descriptor2(&ds_selector, &dword1, &dword2);
     if (!good) {
-      bx_printf("task_switch: bad DS fetch\n");
+      bio->printf("task_switch: bad DS fetch\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ds_selector & 0xfffc;
       goto post_exception;
@@ -718,7 +718,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     if (ds_descriptor.valid==0 || ds_descriptor.segment==0 ||
         (ds_descriptor.u.segment.executable &&
          ds_descriptor.u.segment.r_w==0)) {
-      bx_panic("task_switch: DS not valid\n");
+      bio->panic("task_switch: DS not valid\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ds_selector & 0xfffc;
       goto post_exception;
@@ -727,13 +727,13 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     else if (ds_descriptor.type<12 &&
         (ds_descriptor.dpl<cs_selector.rpl ||
          ds_descriptor.dpl<ds_selector.rpl)) {
-      bx_panic("task_switch: DS.dpl not valid\n");
+      bio->panic("task_switch: DS.dpl not valid\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ds_selector & 0xfffc;
       goto post_exception;
       }
     else if (ds_descriptor.p==0) {
-      bx_panic("task_switch: DS.p==0\n");
+      bio->panic("task_switch: DS.p==0\n");
       exception_no = BX_NP_EXCEPTION;
       error_code   = raw_ds_selector & 0xfffc;
       goto post_exception;
@@ -750,7 +750,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     Boolean good;
     good = fetch_raw_descriptor2(&es_selector, &dword1, &dword2);
     if (!good) {
-      bx_printf("task_switch: bad ES fetch\n");
+      bio->printf("task_switch: bad ES fetch\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_es_selector & 0xfffc;
       goto post_exception;
@@ -760,7 +760,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     if (es_descriptor.valid==0 || es_descriptor.segment==0 ||
         (es_descriptor.u.segment.executable &&
          es_descriptor.u.segment.r_w==0)) {
-      bx_panic("task_switch: ES not valid\n");
+      bio->panic("task_switch: ES not valid\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_es_selector & 0xfffc;
       goto post_exception;
@@ -769,13 +769,13 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     else if (es_descriptor.type<12 &&
         (es_descriptor.dpl<cs_selector.rpl ||
          es_descriptor.dpl<es_selector.rpl)) {
-      bx_panic("task_switch: ES.dpl not valid\n");
+      bio->panic("task_switch: ES.dpl not valid\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_es_selector & 0xfffc;
       goto post_exception;
       }
     else if (es_descriptor.p==0) {
-      bx_panic("task_switch: ES.p==0\n");
+      bio->panic("task_switch: ES.p==0\n");
       exception_no = BX_NP_EXCEPTION;
       error_code   = raw_es_selector & 0xfffc;
       goto post_exception;
@@ -793,7 +793,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     Boolean good;
     good = fetch_raw_descriptor2(&fs_selector, &dword1, &dword2);
     if (!good) {
-      bx_printf("task_switch: bad FS fetch\n");
+      bio->printf("task_switch: bad FS fetch\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_fs_selector & 0xfffc;
       goto post_exception;
@@ -803,7 +803,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     if (fs_descriptor.valid==0 || fs_descriptor.segment==0 ||
         (fs_descriptor.u.segment.executable &&
          fs_descriptor.u.segment.r_w==0)) {
-      bx_panic("task_switch: FS not valid\n");
+      bio->panic("task_switch: FS not valid\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_fs_selector & 0xfffc;
       goto post_exception;
@@ -812,13 +812,13 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     else if (fs_descriptor.type<12 &&
         (fs_descriptor.dpl<cs_selector.rpl ||
          fs_descriptor.dpl<fs_selector.rpl)) {
-      bx_panic("task_switch: FS.dpl not valid\n");
+      bio->panic("task_switch: FS.dpl not valid\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_fs_selector & 0xfffc;
       goto post_exception;
       }
     else if (fs_descriptor.p==0) {
-      bx_panic("task_switch: FS.p==0\n");
+      bio->panic("task_switch: FS.p==0\n");
       exception_no = BX_NP_EXCEPTION;
       error_code   = raw_fs_selector & 0xfffc;
       goto post_exception;
@@ -835,7 +835,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     Boolean good;
     good = fetch_raw_descriptor2(&gs_selector, &dword1, &dword2);
     if (!good) {
-      bx_printf("task_switch: bad GS fetch\n");
+      bio->printf("task_switch: bad GS fetch\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_gs_selector & 0xfffc;
       goto post_exception;
@@ -845,7 +845,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     if (gs_descriptor.valid==0 || gs_descriptor.segment==0 ||
         (gs_descriptor.u.segment.executable &&
          gs_descriptor.u.segment.r_w==0)) {
-      bx_panic("task_switch: GS not valid\n");
+      bio->panic("task_switch: GS not valid\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_gs_selector & 0xfffc;
       goto post_exception;
@@ -854,13 +854,13 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
     else if (gs_descriptor.type<12 &&
         (gs_descriptor.dpl<cs_selector.rpl ||
          gs_descriptor.dpl<gs_selector.rpl)) {
-      bx_panic("task_switch: GS.dpl not valid\n");
+      bio->panic("task_switch: GS.dpl not valid\n");
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_gs_selector & 0xfffc;
       goto post_exception;
       }
     else if (gs_descriptor.p==0) {
-      bx_panic("task_switch: GS.p==0\n");
+      bio->panic("task_switch: GS.p==0\n");
       //exception(BX_NP_EXCEPTION, raw_gs_selector & 0xfffc, 0);
       exception_no = BX_NP_EXCEPTION;
       error_code   = raw_gs_selector & 0xfffc;
@@ -879,7 +879,7 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
   if ((tss_descriptor->type>=9) && (trap_word & 0x0001)) {
     BX_CPU_THIS_PTR debug_trap |= 0x00008000; // BT flag in DR6
     BX_CPU_THIS_PTR async_event = 1; // so processor knows to check
-    bx_printf("task_switch: T bit set in new TSS.\n");
+    bio->printf("task_switch: T bit set in new TSS.\n");
     }
 
 
@@ -887,13 +887,13 @@ BX_CPU_THIS_PTR ldtr.cache.u.ldt.limit =
   //
   // Step 14: Begin execution of new task.
   //
-//fprintf(stderr, "TASKING: LEAVE\n");
+//bio->printf("TASKING: LEAVE\n");
   return;
 
 post_exception:
   BX_CPU_THIS_PTR debug_trap = 0;
   BX_CPU_THIS_PTR inhibit_mask = 0;
-  bx_printf("task switch: posting exception %u after commit point\n",
+  bio->printf("task switch: posting exception %u after commit point\n",
     exception_no);
   exception(exception_no, error_code, 0);
   return;
@@ -904,7 +904,7 @@ post_exception:
 BX_CPU_C::get_SS_ESP_from_TSS(unsigned pl, Bit16u *ss, Bit32u *esp)
 {
   if (BX_CPU_THIS_PTR tr.cache.valid==0)
-    bx_panic("get_SS_ESP_from_TSS: TR.cache invalid\n");
+    bio->panic("get_SS_ESP_from_TSS: TR.cache invalid\n");
 
   if (BX_CPU_THIS_PTR tr.cache.type==9) {
     // 32-bit TSS
@@ -938,7 +938,7 @@ BX_CPU_C::get_SS_ESP_from_TSS(unsigned p
     *esp = temp16; // truncate
     }
   else {
-    bx_panic("get_SS_ESP_from_TSS: TR is bogus type (%u)\n",
+    bio->panic("get_SS_ESP_from_TSS: TR is bogus type (%u)\n",
              (unsigned) BX_CPU_THIS_PTR tr.cache.type);
     }
 }
@@ -964,7 +964,7 @@ BX_CPU_C::task_switch(bx_selector_t *sel
   UNUSED(dword1);
   UNUSED(dword2);
 
-  bx_printf("task_switch(): not complete\n");
+  bio->printf("task_switch(): not complete\n");
 }
 #endif
 
