1 #include "u.h"
2 #include "../port/lib.h"
3 #include "mem.h"
4 #include "dat.h"
5 #include "fns.h"
6
7 int
fpudevprocio(Proc * proc,void * a,long n,uintptr offset,int write)8 fpudevprocio(Proc* proc, void* a, long n, uintptr offset, int write)
9 {
10 /*
11 * Called from procdevtab.read and procdevtab.write
12 * allow user process access to the FPU registers.
13 * This is the only FPU routine which is called directly
14 * from the port code; it would be nice to have dynamic
15 * creation of entries in the device file trees...
16 */
17 USED(proc, a, n, offset, write);
18
19 return 0;
20 }
21
22 void
fpunotify(Ureg *)23 fpunotify(Ureg*)
24 {
25 /*
26 * Called when a note is about to be delivered to a
27 * user process, usually at the end of a system call.
28 * Note handlers are not allowed to use the FPU so
29 * the state is marked (after saving if necessary) and
30 * checked in the Device Not Available handler.
31 */
32 }
33
34 void
fpunoted(void)35 fpunoted(void)
36 {
37 /*
38 * Called from sysnoted() via the machine-dependent
39 * noted() routine.
40 * Clear the flag set above in fpunotify().
41 */
42 }
43
44 void
fpusysrfork(Ureg *)45 fpusysrfork(Ureg*)
46 {
47 /*
48 * Called early in the non-interruptible path of
49 * sysrfork() via the machine-dependent syscall() routine.
50 * Save the state so that it can be easily copied
51 * to the child process later.
52 */
53 }
54
55 void
fpusysrforkchild(Proc *,Ureg *,Proc *)56 fpusysrforkchild(Proc*, Ureg*, Proc*)
57 {
58 /*
59 * Called later in sysrfork() via the machine-dependent
60 * sysrforkchild() routine.
61 * Copy the parent FPU state to the child.
62 */
63 }
64
65 void
fpuprocsave(Proc *)66 fpuprocsave(Proc*)
67 {
68 /*
69 * Called from sched() and sleep() via the machine-dependent
70 * procsave() routine.
71 * About to go in to the scheduler.
72 * If the process wasn't using the FPU
73 * there's nothing to do.
74 */
75 }
76
77 void
fpuprocrestore(Proc *)78 fpuprocrestore(Proc*)
79 {
80 /*
81 * The process has been rescheduled and is about to run.
82 * Nothing to do here right now. If the process tries to use
83 * the FPU again it will cause a Device Not Available
84 * exception and the state will then be restored.
85 */
86 }
87
88 void
fpusysprocsetup(Proc *)89 fpusysprocsetup(Proc*)
90 {
91 /*
92 * Disable the FPU.
93 * Called from sysexec() via sysprocsetup() to
94 * set the FPU for the new process.
95 */
96 }
97
98 void
fpuinit(void)99 fpuinit(void)
100 {
101 }
102
103 int
fpuemu(Ureg * ureg)104 fpuemu(Ureg* ureg)
105 {
106 int nfp;
107
108 if(waserror()){
109 splhi();
110 postnote(up, 1, up->errstr, NDebug);
111 return 1;
112 }
113 spllo();
114 nfp = fpiarm(ureg);
115 splhi();
116 poperror();
117
118 return nfp;
119 }
120