|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /*
26: * Copyright 1994 NeXT Computer, Inc.
27: * All rights reserved.
28: */
29:
30: #import <kern/thread.h>
31:
32: #import <machdep/i386/bios.h>
33: #import <machdep/i386/seg.h>
34:
35: /*
36: * Maintain the recover field in the thread_t structure
37: */
38: static inline void
39: set_recover(int (*vector)())
40: {
41: current_thread()->recover = (vm_offset_t)vector;
42: return;
43: }
44:
45: static inline void
46: clear_recover()
47: {
48: current_thread()->recover = 0;
49: }
50:
51:
52:
53: int volatile
54: bios32(biosBuf_t *bb)
55: {
56: static unsigned long ebp;
57: static unsigned long ss;
58: static boolean_t initialized;
59: static lock_t lock;
60:
61: #if NOTYET // this is failing on the NEC right now
62: if (!initialized) {
63: lock_init(lock, TRUE);
64: initialized = TRUE;
65: }
66:
67: lock_write(lock);
68: set_recover(&&do_fault);
69:
70: /* Save stack pointer. */
71: asm volatile("mov %%ebp, %0"
72: : "=m" (ebp)
73: : /* no inputs */);
74: asm volatile("mov %%ss, %0"
75: : "=m" (ss)
76: : /* no inputs */);
77: #endif NOTYET
78: _bios32(bb);
79:
80:
81: #if NOTYET
82: /* Reload DS, ES, FS, GS and SS. */
83: asm volatile("movw %0, %%ax;"
84: "mov %%ax, %%ds; mov %%ax, %%es;"
85: "mov %1, %%ax; mov %%ax, %%fs;"
86: "mov %2, %%ax; mov %%ax, %%gs;"
87: : /* no outputs */
88: : "i" (KDS_SEL), "i" (LDATA_SEL), "i" (0));
89: asm volatile("mov %0, %%ss"
90: : /* no inputs */
91: : "m" (ss));
92: /* Restore stack pointer. */
93: asm volatile("mov %0, %%ebp"
94: : /* no outputs */
95: : "m" (ebp));
96: clear_recover();
97: lock_done(lock);
98: #endif NOTYET
99: return 0;
100: #if NOTYET
101: do_fault:
102: /* Reload DS, ES, FS, GS and SS. */
103: asm volatile("movw %0, %%ax;"
104: "mov %%ax, %%ds; mov %%ax, %%es;"
105: "mov %1, %%ax; mov %%ax, %%fs;"
106: "mov %2, %%ax; mov %%ax, %%gs;"
107: : /* no outputs */
108: : "i" (KDS_SEL), "i" (LDATA_SEL), "i" (0));
109: asm volatile("mov %0, %%ss"
110: : /* no inputs */
111: : "m" (ss));
112: /* Restore stack pointer. */
113: asm volatile("mov %0, %%ebp"
114: : /* no outputs */
115: : "m" (ebp));
116: clear_recover();
117: lock_done(lock);
118: return -1;
119: #endif NOTYET
120: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.