Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / os-support / bsd / bsd_axp.c
blob51ffef1480c2193415bf7f4d1f8257edb0f6c4fc
2 #ifdef HAVE_XORG_CONFIG_H
3 #include <xorg-config.h>
4 #endif
6 #include <X11/X.h>
7 #include "os.h"
8 #include "xf86.h"
9 #include "xf86Priv.h"
10 #include "xf86Axp.h"
11 #include <sys/param.h>
12 #include "xf86_OSlib.h"
13 #include <stdio.h>
14 #include <sys/sysctl.h>
16 axpDevice bsdGetAXP(void);
19 * BSD does a very nice job providing system information to
20 * user space programs. Unfortunately it doesn't provide all
21 * the information required. Therefore we just obtain the
22 * system type and look up the rest from a list we maintain
23 * ourselves.
26 typedef struct {
27 char *name;
28 int type;
29 } _AXP;
31 static _AXP axpList[] = {
32 {"apecs",APECS},
33 {"pyxis",PYXIS},
34 {"cia",CIA},
35 {"irongate",IRONGATE},
36 {"lca",LCA},
37 {"t2",T2},
38 {"tsunami",TSUNAMI},
39 {NULL,NONE}
42 axpDevice
43 bsdGetAXP(void)
45 int i;
46 char sysname[64];
47 size_t len = sizeof(sysname);
49 #ifdef __OpenBSD__
50 int mib[3];
51 int error;
53 mib[0] = CTL_MACHDEP;
54 mib[1] = CPU_CHIPSET;
55 mib[2] = CPU_CHIPSET_TYPE;
57 if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0)
58 #else
59 if ((sysctlbyname("hw.chipset.type", &sysname, &len,
60 0, 0)) < 0)
61 #endif
62 FatalError("bsdGetAXP: can't find machine type\n");
63 #ifdef DEBUG
64 xf86Msg(X_INFO,"AXP is a: %s\n",sysname);
65 #endif
66 for (i=0;;i++) {
67 if (axpList[i].name == NULL)
68 return NONE;
69 if (!strcmp(sysname, axpList[i].name))
70 return axpList[i].type;