]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/xen/archxen.c
audiosb16: cleanup audioprobe(), cast ISAConf.port to ulong
[plan9front.git] / sys / src / 9 / xen / archxen.c
1 #include "u.h"
2 #include "../port/lib.h"
3 #include "mem.h"
4 #include "dat.h"
5 #include "fns.h"
6 #include "io.h"
7
8 static int
9 identify(void)
10 {
11         m->havepge = 0;
12         return 0;
13 }
14
15 static void
16 intrinit(void)
17 {
18         ulong machs;
19         int i, ncpu;
20         char *cp;
21         char node[32];
22         char buf[32];
23
24         if((cp = getconf("*nomp")) != nil && strtol(cp, 0, 0) != 0)
25                 return;
26         ncpu = MAX_VIRT_CPUS;
27         if (cp = getconf("*ncpu")) {
28                 ncpu = strtol(cp, 0, 0);
29                 if (ncpu < 1)
30                         ncpu = 1;
31         }
32         machs = 1;
33         for (i = 1; i < ncpu; i++) {
34                 sprint(node, "cpu/%d/availability", i);
35                 if (xenstore_read(node, buf, sizeof buf) <= 0)
36                         break;
37                 print("%s: %s\n", node, buf);
38                 if (strcmp(buf, "online") == 0) {
39                         machs |= 1<<i;
40                         conf.nmach++;
41                 }
42         }
43         if (conf.nmach > 1) {
44                 print("Sorry, SMP not supported yet: 1 of %lud CPUs startd\n", conf.nmach);
45                 conf.nmach = 1;
46         }
47 }
48
49 static void
50 shutdown(void)
51 {
52         HYPERVISOR_shutdown(1);
53 }
54
55 int xenintrenable(Vctl *v);
56 int xenintrvecno(int irq);
57 int xenintrdisable(int irq);
58 void    xentimerenable(void);
59 uvlong  xentimerread(uvlong*);
60 void    xentimerset(uvlong);
61
62 PCArch archxen = {
63 .id=            "Xen",  
64 .ident=         identify,
65 .reset=         shutdown,
66 .intrinit=      intrinit,
67 .intrenable=    xenintrenable,
68 .intrvecno=     xenintrvecno,
69 .intrdisable=   xenintrdisable,
70 .clockenable=   xentimerenable,
71 .fastclock=     xentimerread,
72 .timerset=      xentimerset,
73 };
74
75 /*
76  * Placeholders to satisfy external references in generic devarch.c
77  */
78 ulong   getcr4(void)    { return 0; }
79 void    putcr4(ulong)   {}
80 int     inb(int)        { return 0; }
81 ushort  ins(int)        { return 0; }
82 ulong   inl(int)        { return 0; }
83 void    outb(int, int)  {}
84 void    outs(int, ushort)       {}
85 void    outl(int, ulong)        {}
86 void    i8042reset(void)        {}
87 void    i8253enable(void)       {}
88 void    i8253init(void) {}
89 void    i8253link(void) {}
90 uvlong  i8253read(uvlong*)      { return 0; }
91 void    i8253timerset(uvlong)   {}
92 int     i8259disable(int)       { return 0; }
93 int     i8259enable(Vctl*)      { return 0; }
94 void    i8259init(void) {}
95 int     i8259isr(int)   { return 0; }
96 void    i8259on(void)   {}
97 void    i8259off(void)  {}
98 int     i8259vecno(int) { return 0; }
99 int     mtrrprint(char*, long) { return 0; }
100 char*   mtrr(uvlong, uvlong, char *) { return nil; }
101 void    mtrrsync(void) {}
102
103 /*
104  * XXX until fpsave is debugged
105  */
106 void
107 fpssesave(FPsave* f)
108 {
109         fpx87save(f);
110 }
111
112 void
113 fpsserestore(FPsave* f)
114 {
115         fpx87restore(f);
116 }