[BACK]Return to cpu.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / alpha / alpha

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/arch/alpha/alpha/cpu.c between version 1.90 and 1.90.6.1

version 1.90, 2010/12/17 02:36:35 version 1.90.6.1, 2011/06/23 14:18:50
Line 67  __KERNEL_RCSID(0, "$NetBSD$");
Line 67  __KERNEL_RCSID(0, "$NetBSD$");
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/systm.h>  #include <sys/systm.h>
 #include <sys/device.h>  #include <sys/device.h>
 #include <sys/malloc.h>  #include <sys/kmem.h>
 #include <sys/proc.h>  #include <sys/proc.h>
 #include <sys/atomic.h>  #include <sys/atomic.h>
 #include <sys/cpu.h>  #include <sys/cpu.h>
Line 111  void cpu_boot_secondary(struct cpu_info 
Line 111  void cpu_boot_secondary(struct cpu_info 
 u_long  cpu_implver, cpu_amask;  u_long  cpu_implver, cpu_amask;
   
 /* Definition of the driver for autoconfig. */  /* Definition of the driver for autoconfig. */
 static int      cpumatch(struct device *, struct cfdata *, void *);  static int      cpumatch(device_t, cfdata_t, void *);
 static void     cpuattach(struct device *, struct device *, void *);  static void     cpuattach(device_t, device_t, void *);
   
 CFATTACH_DECL(cpu, sizeof(struct cpu_softc),  CFATTACH_DECL_NEW(cpu, sizeof(struct cpu_softc),
     cpumatch, cpuattach, NULL, NULL);      cpumatch, cpuattach, NULL, NULL);
   
 static void     cpu_announce_extensions(struct cpu_info *);  static void     cpu_announce_extensions(struct cpu_info *);
   
 extern struct cfdriver cpu_cd;  extern struct cfdriver cpu_cd;
   
 static const char *lcaminor[] = {  static const char * const lcaminor[] = {
         "",          "",
         "21066", "21066",          "21066", "21066",
         "21068", "21068",          "21068", "21068",
         "21066A", "21068A", 0          "21066A", "21068A", 0
 };  };
   
 struct cputable_struct {  const struct cputable_struct {
         int     cpu_major_code;          int     cpu_major_code;
         const char *cpu_major_name;          const char *cpu_major_name;
         const char **cpu_minor_names;          const char * const *cpu_minor_names;
 } cpunametable[] = {  } cpunametable[] = {
         { PCS_PROC_EV3,         "EV3",          NULL            },          { PCS_PROC_EV3,         "EV3",          NULL            },
         { PCS_PROC_EV4,         "21064",        NULL            },          { PCS_PROC_EV4,         "21064",        NULL            },
Line 176  struct cputable_struct {
Line 176  struct cputable_struct {
  */   */
   
 static int  static int
 cpumatch(struct device *parent, struct cfdata *cfdata, void *aux)  cpumatch(device_t parent, cfdata_t cfdata, void *aux)
 {  {
         struct mainbus_attach_args *ma = aux;          struct mainbus_attach_args *ma = aux;
   
Line 191  cpumatch(struct device *parent, struct c
Line 191  cpumatch(struct device *parent, struct c
 }  }
   
 static void  static void
 cpuattach(struct device *parent, struct device *self, void *aux)  cpuattach(device_t parent, device_t self, void *aux)
 {  {
         struct cpu_softc *sc = (void *) self;          struct cpu_softc * const sc = device_private(self);
         struct mainbus_attach_args *ma = aux;          struct mainbus_attach_args *ma = aux;
         int i;          int i;
         const char **s;          const char * const *s;
         struct pcs *p;          struct pcs *p;
 #ifdef DEBUG  
         int needcomma;  
 #endif  
         u_int32_t major, minor;          u_int32_t major, minor;
         struct cpu_info *ci;          struct cpu_info *ci;
   
           sc->sc_dev = self;
   
         p = LOCATE_PCS(hwrpb, ma->ma_slot);          p = LOCATE_PCS(hwrpb, ma->ma_slot);
         major = PCS_CPU_MAJORTYPE(p);          major = PCS_CPU_MAJORTYPE(p);
         minor = PCS_CPU_MINORTYPE(p);          minor = PCS_CPU_MINORTYPE(p);
   
         printf(": ID %d%s, ", ma->ma_slot,          aprint_normal(": ID %d%s, ", ma->ma_slot,
             ma->ma_slot == hwrpb->rpb_primary_cpu_id ? " (primary)" : "");              ma->ma_slot == hwrpb->rpb_primary_cpu_id ? " (primary)" : "");
   
         for(i = 0; i < sizeof cpunametable / sizeof cpunametable[0]; ++i) {          for(i = 0; i < __arraycount(cpunametable); ++i) {
                 if (cpunametable[i].cpu_major_code == major) {                  if (cpunametable[i].cpu_major_code == major) {
                         printf("%s-%d", cpunametable[i].cpu_major_name, minor);                          aprint_normal("%s-%d",
                               cpunametable[i].cpu_major_name, minor);
                         s = cpunametable[i].cpu_minor_names;                          s = cpunametable[i].cpu_minor_names;
                         for(i = 0; s && s[i]; ++i) {                          for(i = 0; s && s[i]; ++i) {
                                 if (i == minor && strlen(s[i]) != 0) {                                  if (i == minor && strlen(s[i]) != 0) {
                                         printf(" (%s)\n", s[i]);                                          aprint_normal(" (%s)\n", s[i]);
                                         goto recognized;                                          goto recognized;
                                 }                                  }
                         }                          }
                         goto recognized;                          goto recognized;
                 }                  }
         }          }
         printf("UNKNOWN CPU TYPE (%d:%d)", major, minor);          aprint_error("UNKNOWN CPU TYPE (%d:%d)", major, minor);
   
 recognized:  recognized:
         printf("\n");          aprint_naive("\n");
           aprint_normal("\n");
   
 #ifdef DEBUG  #ifdef DEBUG
         if (p->pcs_proc_var != 0) {          if (p->pcs_proc_var != 0) {
                 printf("%s: ", sc->sc_dev.dv_xname);                  bool needcomma = false;
                   const char *vaxfp = "";
                   const char *ieeefp = "";
                   const char *pe = "";
   
                 needcomma = 0;  
                 if (p->pcs_proc_var & PCS_VAR_VAXFP) {                  if (p->pcs_proc_var & PCS_VAR_VAXFP) {
                         printf("VAX FP support");                          fpstr = "VAX FP support";
                         needcomma = 1;                          needcomma = true;
                 }                  }
                 if (p->pcs_proc_var & PCS_VAR_IEEEFP) {                  if (p->pcs_proc_var & PCS_VAR_IEEEFP) {
                         printf("%sIEEE FP support", needcomma ? ", " : "");                          ieeefp = ", IEEE FP support";
                         needcomma = 1;                          if (!needcomma)
                                   ieeefp += 2;
                           needcomma = true;
                 }                  }
                 if (p->pcs_proc_var & PCS_VAR_PE) {                  if (p->pcs_proc_var & PCS_VAR_PE) {
                         printf("%sPrimary Eligible", needcomma ? ", " : "");                          pe = ", Primary Eligible");
                         needcomma = 1;                          if (!needcomma)
                                   pe += 2;
                           needcomma = true;
                 }                  }
                   aprint_debug_dev(sc->sc_dev, "%s%s%s", vaxfp, ieeefp, pe);
                 if (p->pcs_proc_var & PCS_VAR_RESERVED)                  if (p->pcs_proc_var & PCS_VAR_RESERVED)
                         printf("%sreserved bits: 0x%lx", needcomma ? ", " : "",                          aprint_debug("%sreserved bits: %#lx",
                               needcomma ? ", " : "",
                             p->pcs_proc_var & PCS_VAR_RESERVED);                              p->pcs_proc_var & PCS_VAR_RESERVED);
                 printf("\n");                  aprint_debug("\n");
         }          }
 #endif  #endif
   
         if (ma->ma_slot > ALPHA_WHAMI_MAXID) {          if (ma->ma_slot > ALPHA_WHAMI_MAXID) {
                 if (ma->ma_slot == hwrpb->rpb_primary_cpu_id)                  if (ma->ma_slot == hwrpb->rpb_primary_cpu_id)
                         panic("cpu_attach: primary CPU ID too large");                          panic("cpu_attach: primary CPU ID too large");
                 printf("%s: procssor ID too large, ignoring\n",                  aprint_error_dev(sc->sc_dev,
                     sc->sc_dev.dv_xname);                      "processor ID too large, ignoring\n");
                 return;                  return;
         }          }
   
         if (ma->ma_slot == hwrpb->rpb_primary_cpu_id)          if (ma->ma_slot == hwrpb->rpb_primary_cpu_id)
                 ci = &cpu_info_primary;                  ci = &cpu_info_primary;
         else {          else {
                 ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK);                  ci = kmem_zalloc(sizeof(*ci), KM_SLEEP);
                 memset(ci, 0, sizeof(*ci));  
         }          }
 #if defined(MULTIPROCESSOR)  #if defined(MULTIPROCESSOR)
         cpu_info[ma->ma_slot] = ci;          cpu_info[ma->ma_slot] = ci;
Line 288  recognized:
Line 296  recognized:
         if ((p->pcs_flags & PCS_PA) == 0) {          if ((p->pcs_flags & PCS_PA) == 0) {
                 if (ma->ma_slot == hwrpb->rpb_primary_cpu_id)                  if (ma->ma_slot == hwrpb->rpb_primary_cpu_id)
                         panic("cpu_attach: primary not available?!");                          panic("cpu_attach: primary not available?!");
                 printf("%s: processor not available for use\n",                  aprint_normal_dev(sc->sc_dev,
                     sc->sc_dev.dv_xname);                      "processor not available for use\n");
                 return;                  return;
         }          }
   
Line 297  recognized:
Line 305  recognized:
         if ((p->pcs_flags & PCS_PV) == 0) {          if ((p->pcs_flags & PCS_PV) == 0) {
                 if (ma->ma_slot == hwrpb->rpb_primary_cpu_id)                  if (ma->ma_slot == hwrpb->rpb_primary_cpu_id)
                         panic("cpu_attach: primary has invalid PALcode?!");                          panic("cpu_attach: primary has invalid PALcode?!");
                 printf("%s: PALcode not valid\n", sc->sc_dev.dv_xname);                  aprint_error_dev(sc->sc_dev, "PALcode not valid\n");
                 return;                  return;
         }          }
 #endif /* MULTIPROCESSOR */  #endif /* MULTIPROCESSOR */
Line 319  recognized:
Line 327  recognized:
   
                 error = mi_cpu_attach(ci);                  error = mi_cpu_attach(ci);
                 if (error != 0) {                  if (error != 0) {
                         aprint_error("%s: mi_cpu_attach failed with %d\n",                          aprint_error_dev(sc->sc_dev,
                             sc->sc_dev.dv_xname, error);                              "mi_cpu_attach failed with %d\n", error);
                         return;                          return;
                 }                  }
   
Line 337  recognized:
Line 345  recognized:
                 ci->ci_next = cpu_info_list->ci_next;                  ci->ci_next = cpu_info_list->ci_next;
                 cpu_info_list->ci_next = ci;                  cpu_info_list->ci_next = ci;
 #else /* ! MULTIPROCESSOR */  #else /* ! MULTIPROCESSOR */
                 printf("%s: processor off-line; multiprocessor support "                  aprint_normal_dev(sc->sc_dev, "processor off-line; "
                     "not present in kernel\n", sc->sc_dev.dv_xname);                      "multiprocessor support not present in kernel\n");
 #endif /* MULTIPROCESSOR */  #endif /* MULTIPROCESSOR */
         }          }
   
         evcnt_attach_dynamic(&sc->sc_evcnt_clock, EVCNT_TYPE_INTR,          evcnt_attach_dynamic(&sc->sc_evcnt_clock, EVCNT_TYPE_INTR,
             NULL, sc->sc_dev.dv_xname, "clock");              NULL, device_xname(sc->sc_dev), "clock");
         evcnt_attach_dynamic(&sc->sc_evcnt_device, EVCNT_TYPE_INTR,          evcnt_attach_dynamic(&sc->sc_evcnt_device, EVCNT_TYPE_INTR,
             NULL, sc->sc_dev.dv_xname, "device");              NULL, device_xname(sc->sc_dev), "device");
 #if defined(MULTIPROCESSOR)  #if defined(MULTIPROCESSOR)
         alpha_ipi_init(ci);          alpha_ipi_init(ci);
 #endif  #endif
Line 366  cpu_announce_extensions(struct cpu_info 
Line 374  cpu_announce_extensions(struct cpu_info 
                 cpu_amask = amask;                  cpu_amask = amask;
         } else {          } else {
                 if (implver < cpu_implver)                  if (implver < cpu_implver)
                         printf("%s: WARNING: IMPLVER %lu < %lu\n",                          aprint_error_dev(ci->ci_softc->sc_dev,
                             ci->ci_softc->sc_dev.dv_xname,                              "WARNING: IMPLVER %lu < %lu\n",
                             implver, cpu_implver);                              implver, cpu_implver);
   
                 /*                  /*
Line 380  cpu_announce_extensions(struct cpu_info 
Line 388  cpu_announce_extensions(struct cpu_info 
         if (amask) {          if (amask) {
                 snprintb(bits, sizeof(bits),                  snprintb(bits, sizeof(bits),
                     ALPHA_AMASK_BITS, cpu_amask);                      ALPHA_AMASK_BITS, cpu_amask);
                 printf("%s: Architecture extensions: %s\n",                  aprint_normal_dev(ci->ci_softc->sc_dev,
                     ci->ci_softc->sc_dev.dv_xname, bits);                      "Architecture extensions: %s\n", bits);
         }          }
 }  }
   
Line 457  cpu_boot_secondary(struct cpu_info *ci)
Line 465  cpu_boot_secondary(struct cpu_info *ci)
   
         /* Send a "START" command to the secondary CPU's console. */          /* Send a "START" command to the secondary CPU's console. */
         if (cpu_iccb_send(ci->ci_cpuid, "START\r\n")) {          if (cpu_iccb_send(ci->ci_cpuid, "START\r\n")) {
                 printf("%s: unable to issue `START' command\n",                  aprint_error_dev(ci->ci_softc->sc_dev,
                     ci->ci_softc->sc_dev.dv_xname);                      "unable to issue `START' command\n");
                 return;                  return;
         }          }
   
Line 470  cpu_boot_secondary(struct cpu_info *ci)
Line 478  cpu_boot_secondary(struct cpu_info *ci)
                 delay(1000);                  delay(1000);
         }          }
         if (timeout == 0)          if (timeout == 0)
                 printf("%s: processor failed to boot\n",                  aprint_error_dev(ci->ci_softc->sc_dev,
                     ci->ci_softc->sc_dev.dv_xname);                      "processor failed to boot\n");
   
         /*          /*
          * ...and now wait for verification that it's running kernel           * ...and now wait for verification that it's running kernel
Line 484  cpu_boot_secondary(struct cpu_info *ci)
Line 492  cpu_boot_secondary(struct cpu_info *ci)
                 delay(1000);                  delay(1000);
         }          }
         if (timeout == 0)          if (timeout == 0)
                 printf("%s: processor failed to hatch\n",                  aprint_error_dev(ci->ci_softc->sc_dev,
                     ci->ci_softc->sc_dev.dv_xname);                      "processor failed to hatch\n");
 }  }
   
 void  void
Line 520  cpu_halt(void)
Line 528  cpu_halt(void)
         u_long cpu_id = cpu_number();          u_long cpu_id = cpu_number();
         struct pcs *pcsp = LOCATE_PCS(hwrpb, cpu_id);          struct pcs *pcsp = LOCATE_PCS(hwrpb, cpu_id);
   
         printf("%s: shutting down...\n", ci->ci_softc->sc_dev.dv_xname);          aprint_normal_dev(ci->ci_softc->sc_dev, "shutting down...\n");
   
         pcsp->pcs_flags &= ~(PCS_RC | PCS_HALT_REQ);          pcsp->pcs_flags &= ~(PCS_RC | PCS_HALT_REQ);
         pcsp->pcs_flags |= PCS_HALT_STAY_HALTED;          pcsp->pcs_flags |= PCS_HALT_STAY_HALTED;
Line 660  cpu_debug_dump(void)
Line 668  cpu_debug_dump(void)
         struct cpu_info *ci;          struct cpu_info *ci;
         CPU_INFO_ITERATOR cii;          CPU_INFO_ITERATOR cii;
   
         db_printf("addr         dev     id      flags   ipis    curproc         fpcurproc\n");          db_printf("addr         dev     id      flags   ipis    curproc\n");
         for (CPU_INFO_FOREACH(cii, ci)) {          for (CPU_INFO_FOREACH(cii, ci)) {
                 db_printf("%p   %s      %lu     %lx     %lx     %p      %p\n",                  db_printf("%p   %s      %lu     %lx     %lx     %p\n",
                     ci,                      ci,
                     ci->ci_softc->sc_dev.dv_xname,                      device_xname(ci->ci_softc->sc_dev),
                     ci->ci_cpuid,                      ci->ci_cpuid,
                     ci->ci_flags,                      ci->ci_flags,
                     ci->ci_ipis,                      ci->ci_ipis,
                     ci->ci_curlwp,                      ci->ci_curlwp);
                     ci->ci_fpcurlwp);  
         }          }
 }  }
   

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.90.6.1

CVSweb <webmaster@jp.NetBSD.org>