From da942337841c41c4ed6abe3b0eee9a753d551b6f Mon Sep 17 00:00:00 2001
From: rsc <rsc>
Date: Mon, 27 Aug 2007 16:12:08 +0000
Subject: [PATCH] nits

---
 mp.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/mp.c b/mp.c
index c9a6172..ee74734 100644
--- a/mp.c
+++ b/mp.c
@@ -72,8 +72,7 @@ mp_search(void)
   if((p = (bda[0x0F]<<8)|bda[0x0E])){
     if((mp = mp_scan((uchar*) p, 1024)))
       return mp;
-  }
-  else{
+  }else{
     p = ((bda[0x14]<<8)|bda[0x13])*1024;
     if((mp = mp_scan((uchar*)p-1024, 1024)))
       return mp;
@@ -94,19 +93,20 @@ mp_detect(void)
   uint length;
 
   if((mp = mp_search()) == 0 || mp->physaddr == 0)
-    return 1;
+    return -1;
 
   pcmp = (struct mpctb*) mp->physaddr;
-  if(memcmp(pcmp, "PCMP", 4))
-    return 2;
+  if(memcmp(pcmp, "PCMP", 4) != 0)
+    return -1;
+  if(pcmp->version != 1 && pcmp->version != 4)
+    return -1;
 
   length = pcmp->length;
   sum = 0;
   for(p = (uchar*)pcmp; length; length--)
     sum += *p++;
-
-  if(sum || (pcmp->version != 1 && pcmp->version != 4))
-    return 3;
+  if(sum != 0)
+    return -1;
 
   return 0;
 }
@@ -114,20 +114,17 @@ mp_detect(void)
 void
 mp_init(void)
 {
-  int r;
+  int i, r;
   uchar *p, *e;
   struct mpctb *mpctb;
   struct mppe *proc;
   struct mpbe *bus;
   struct mpioapic *ioapic;
   struct mpie *intr;
-  int i;
-  uchar byte;
 
   ncpu = 0;
-  if((r = mp_detect()) != 0) {
+  if(mp_detect() < 0)
     return;
-  }
 
   ismp = 1;
 
@@ -179,11 +176,10 @@ mp_init(void)
   }
 
   if(mp->imcrp) {
-    // It appears that Bochs doesn't support IMCR, so code won't run.
+    // Bochs doesn't support IMCR, so this doesn't run on Bochs.
+    // But it would on real hardware.
     outb(0x22, 0x70);   // Select IMCR
-    byte = inb(0x23);   // Current contents
-    byte |= 0x01;       // Mask external INTR
-    outb(0x23, byte);   // Disconnect 8259s/NMI
+    outb(0x23, inb(0x23) | 1);  // Mask external interrupts.
   }
 }
 
-- 
GitLab