View | Details | Raw Unified | Return to bug 115415
Collapse All | Expand All

(-)hwinfo-13.3/src/hd/sys.c (-18 / +68 lines)
Lines 43-49 void hd_scan_sys(hd_data_t *hd_data) Link Here
43
  sys_info_t *st;
43
  sys_info_t *st;
44
  hal_device_t *hal;
44
  hal_device_t *hal;
45
#if defined(__PPC__) || defined(__sparc__)
45
#if defined(__PPC__) || defined(__sparc__)
46
  char buf0[80], *s, *t;
46
  FILE *f;
47
  size_t r;
48
  char buf0[256], *s, *t;
47
  str_list_t *sl;
49
  str_list_t *sl;
48
#endif
50
#endif
49
51
Lines 68-104 void hd_scan_sys(hd_data_t *hd_data) Link Here
68
  }
70
  }
69
71
70
#ifdef __PPC__
72
#ifdef __PPC__
73
  /*
74
   * system_type is a hint for yast2-storage to make the correct decision
75
   * for the partition layout, the make the underlying firmware happy.
76
   * perl-Bootloader (who gets it from lilo --get-arch) uses its own version of this logic:
77
   * there is 'PReP' from grep PReP /proc/cpuinfo
78
   * there is 'iSeries' from test -d /proc/iSeries
79
   * there is 'pegasos' from grep -w Pegasos2 /proc/device-tree/model
80
   * there is 'CHRP' from grep -w chrp /proc/device-tree/device_type
81
   * there is 'CHRP' from grep -w chrp-cbea /proc/device-tree/device_type
82
   * there is 'MacRISC' or 'MacRISC4' from grep -w 'MacRISC[4]?' /proc/device-tree/compatible
83
   *   PowerMacs have 2 classes, OldWorld and NewWorld (NuBus is unsupported)
84
   *   OldWorld better use BootX to boot the kernel because the OF is not mature enough
85
   *   NewWorld boot support from OpenFirmware is reliable
86
   *   the presence of an dir entry 'interrupt-controller' below /proc/device-tree flags NewWorld
87
   *   MacRISC is always 32bit, MacRISC4 is 64bit
88
   *   MacRISC2 and MacRISC3 are additional compatible properties, but they are unused
89
   * there are a few custom boards that do not have the expected strings in model or device_type
90
   *   map 'model' "Momentum,Maple-D", "Momentum,Maple-L" and "Momentum,Maple" to 'chrp'
91
   *
92
   *  in addition to the system_type property, unconditionally export /proc/device-tree/model
93
   *  This gives some info about the PowerMac and pSeries model
94
   */
71
  for(sl = hd_data->cpu; sl; sl = sl->next) {
95
  for(sl = hd_data->cpu; sl; sl = sl->next) {
72
    if(sscanf(sl->str, "motherboard : %79[^\n]", buf0) == 1) {
73
      if((s = strstr(buf0, "MacRISC"))) {
74
        for(t = s + sizeof "MacRISC" - 1; isalnum(*t); t++);
75
        *t = 0;
76
        st->system_type = new_str(s);
77
        hd_data->flags.no_parport = 1;
78
      }
79
    }
80
    if(sscanf(sl->str, "machine : %79[^\n]", buf0) == 1) {
96
    if(sscanf(sl->str, "machine : %79[^\n]", buf0) == 1) {
81
      if(strstr(buf0, "PReP")) {
97
      if(strstr(buf0, "PReP")) {
82
        st->system_type = new_str("PReP");
98
        st->system_type = new_str("PReP");
83
      }
99
      }
84
      else if(strstr(buf0, "CHRP")) {
85
        st->system_type = new_str(/* is_64 ? "CHRP64" : */ "CHRP");
86
      }
87
      else if(strstr(buf0, "iSeries")) {
100
      else if(strstr(buf0, "iSeries")) {
88
        st->system_type = new_str("iSeries");
101
        st->system_type = new_str("iSeries");
89
        hd_data->flags.iseries = 1;
102
        hd_data->flags.iseries = 1;
90
      }
103
      }
91
      if(strstr(buf0, "PowerBook2,")) {
92
        st->model = new_str("iBook");
93
      }
94
      else if(strstr(buf0, "PowerBook")) {
95
        st->model = new_str("PowerBook");
96
      }
97
    }
104
    }
98
    if(sscanf(sl->str, "pmac-generation : %79[^\n]", buf0) == 1) {
105
    if(sscanf(sl->str, "pmac-generation : %79[^\n]", buf0) == 1) {
99
      st->generation = new_str(buf0);
106
      st->generation = new_str(buf0);
100
    }
107
    }
101
  }
108
  }
109
  f = fopen("/proc/device-tree/model", "r");
110
  if(f) {
111
    r = fread(buf0, 1, sizeof(buf0) - 1, f);
112
    if(r > 0 && r < sizeof(buf0)) {
113
      buf0[r] = '\0';
114
      st->model = new_str(buf0);
115
      if(strcmp(buf0, "Pegasos2") == 0)
116
        st->system_type = new_str("pegasos");
117
      else if (strcmp(buf0, "Momentum,Maple-D") == 0 || strcmp(buf0, "Momentum,Maple-L") == 0 || strcmp(buf0, "Momentum,Maple") == 0)
118
        st->system_type = new_str("CHRP");
119
    }
120
    fclose(f);
121
  }
122
  if(!st->system_type) {
123
    f = fopen("/proc/device-tree/device_type", "r");
124
    if(f) {
125
      r = fread(buf0, 1, sizeof(buf0) - 1, f);
126
      if(r > 0 && r < sizeof(buf0)) {
127
        buf0[r] = '\0';
128
	/* pSeries and cell */
129
	if(strcmp(buf0, "chrp") == 0 || strcmp(buf0, "chrp-cbea") == 0)
130
		st->system_type = new_str("CHRP");
131
      }
132
      fclose(f);
133
    }
134
  }
135
  if(!st->system_type) {
136
    f = fopen("/proc/device-tree/compatible", "r");
137
    if(f) {
138
      r = fread(buf0, 1, sizeof(buf0) - 1, f);
139
      if(r > 0 && r < sizeof(buf0)) {
140
        buf0[r] = '\0';
141
	for(r = r - sizeof("MacRISC") - 1; r; r--) {
142
	  if(memcmp(&buf0[r], "MacRISC", sizeof("MacRISC") - 1) == 0) {
143
            st->system_type = new_str("MacRISC");
144
            hd_data->flags.no_parport = 1;
145
            break;
146
	  }
147
	}
148
      }
149
      fclose(f);
150
    }
151
  }
102
#endif	/* __PPC__ */
152
#endif	/* __PPC__ */
103
153
104
#ifdef __sparc__
154
#ifdef __sparc__

Return to bug 115415