Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / net-snmp / agent / mibgroup / host / hr_other.c
1 /*
2  *  Host Resources MIB - other device implementation - hr_other.c
3  *
4  */
5
6 #include <net-snmp/net-snmp-config.h>
7
8 #include "host_res.h"
9 #include "hr_other.h"
10
11 #if HAVE_UNISTD_H
12 #include <unistd.h>
13 #endif
14
15
16 void            Init_HR_CPU(void);
17 int             Get_Next_HR_CPU(void);
18 const char     *describe_cpu(int);
19
20 void            Init_HR_CoProc(void);
21 int             Get_Next_HR_CoProc(void);
22 const char     *describe_coproc(int);
23
24 void
25 init_hr_other(void)
26 {
27     init_device[HRDEV_PROC] = Init_HR_CPU;
28     next_device[HRDEV_PROC] = Get_Next_HR_CPU;
29     device_descr[HRDEV_PROC] = describe_cpu;
30
31     init_device[HRDEV_COPROC] = Init_HR_CoProc;
32     next_device[HRDEV_COPROC] = Get_Next_HR_CoProc;
33     device_descr[HRDEV_COPROC] = describe_coproc;
34 }
35
36
37 static int      done_CPU;
38
39 void
40 Init_HR_CPU(void)
41 {
42     done_CPU = 0;
43 }
44
45 int
46 Get_Next_HR_CPU(void)
47 {
48     /*
49      * Assumes a single CPU system
50      * I think it's safe to assume at least one! 
51      */
52     if (done_CPU != 1) {
53         done_CPU = 1;
54         return (HRDEV_PROC << HRDEV_TYPE_SHIFT);
55     } else
56         return -1;
57 }
58
59 const char     *
60 describe_cpu(int idx)
61 {
62 #ifdef _SC_CPU_VERSION
63     int             result;
64
65     result = sysconf(_SC_CPU_VERSION);
66     switch (result) {
67     case CPU_HP_MC68020:
68         return (" Motorola MC68020 ");
69     case CPU_HP_MC68030:
70         return (" Motorola MC68030 ");
71     case CPU_HP_MC68040:
72         return (" Motorola MC68040 ");
73     case CPU_PA_RISC1_0:
74         return (" HP PA-RISC 1.0 ");
75     case CPU_PA_RISC1_1:
76         return (" HP PA-RISC 1.1 ");
77     case CPU_PA_RISC1_2:
78         return (" HP PA-RISC 1.2 ");
79     case CPU_PA_RISC2_0:
80         return (" HP PA-RISC 2.0 ");
81     default:
82         return ("An electronic chip with an HP label");
83
84     }
85 #else
86     return ("An electronic chip that makes the computer work.");
87 #endif
88 }
89
90
91
92 static int      done_coProc;
93
94 void
95 Init_HR_CoProc(void)
96 {
97     done_coProc = 0;
98 }
99
100 int
101 Get_Next_HR_CoProc(void)
102 {
103     /*
104      * How to identify the presence of a co-processor ? 
105      */
106
107     if (done_coProc != 1) {
108         done_coProc = 1;
109         return (HRDEV_COPROC << HRDEV_TYPE_SHIFT);
110     } else
111         return -1;
112 }
113
114
115 const char     *
116 describe_coproc(int idx)
117 {
118     return ("Guessing that there's a floating point co-processor");
119 }