|
|
1.1 root 1: /*-
2: * Copyright (c) 1990 The Regents of the University of California.
3: * All rights reserved.
4: *
5: * This code is derived from software contributed to Berkeley by
6: * William Jolitz.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by the University of
19: * California, Berkeley and its contributors.
20: * 4. Neither the name of the University nor the names of its contributors
21: * may be used to endorse or promote products derived from this software
22: * without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34: * SUCH DAMAGE.
35: *
36: * @(#)srt0.c 5.3 (Berkeley) 4/28/91
37: */
38:
39: /*
40: * Startup code for standalone system
41: * Non-relocating version -- for programs which are loaded by boot
42: * Relocating version for boot
43: * Small relocating version for "micro" boot
44: */
45:
46: .globl _end
47: .globl _edata
48: .globl _main
49: .globl __rtt
50: .globl _exit
51: .globl _bootdev
52: .globl _cyloffset
1.1.1.3 ! root 53: #define NOP inb $0x84,%al ; inb $0x84,%al
1.1 root 54:
55: #ifdef SMALL
56: /* where the disklabel goes if we have one */
57: .globl _disklabel
58: _disklabel:
59: .space 512
1.1.1.3 ! root 60: .globl _scsisn
! 61: .set _scsisn, RELOC+0x60
1.1 root 62: #endif
63:
1.1.1.2 root 64: .globl entry
65: .set entry,0
1.1 root 66: .globl start
67:
68: #if defined(REL) && !defined(SMALL)
69:
70: /* relocate program and enter at symbol "start" */
71:
72: #movl $entry-RELOC,%esi # from beginning of ram
73: movl $0,%esi
74: #movl $entry,%edi # to relocated area
75: movl $ RELOC,%edi # to relocated area
76: # movl $_edata-RELOC,%ecx # this much
77: movl $64*1024,%ecx
78: cld
79: rep
80: movsb
81: # relocate program counter to relocation base
82: pushl $start
83: ret
84: #endif
85:
86: start:
87:
88: /* setup stack pointer */
89:
90: #ifdef REL
91: leal 4(%esp),%eax /* ignore old pc */
1.1.1.3 ! root 92: movl $ RELOC-3*4,%ebx
! 93: /* copy boot parameters */
1.1 root 94: pushl $3*4
95: pushl %ebx
96: pushl %eax
97: call _bcopy
98: movl %ebx,%esp
99: #else
100: /* save old stack state */
101: movl %esp,savearea
102: movl %ebp,savearea+4
103: movl $ RELOC-0x2400,%esp
104: #endif
105:
106: /* clear memory as needed */
107:
108: movl %esp,%esi
109: #ifdef REL
110:
111: /*
112: * Clear Bss and up to 64K heap
113: */
114: movl $64*1024,%ebx
115: movl $_end,%eax # should be movl $_end-_edata but ...
116: subl $_edata,%eax
1.1.1.3 ! root 117: #addl %ebx,%eax
1.1 root 118: pushl %eax
119: pushl $_edata
120: call _bzero
121:
122: /*
123: * Clear 64K of stack
124: */
125: movl %esi,%eax
126: subl %ebx,%eax
127: subl $5*4,%ebx
128: pushl %ebx
129: pushl %eax
130: call _bzero
131: #else
132: movl $_edata,%edx
133: movl %esp,%eax
134: subl %edx,%eax
135: pushl %edx
136: pushl %esp
137: call _bzero
138: #endif
139:
140: call _kbdreset /* resets keyboard and gatea20 brain damage */
1.1.1.3 ! root 141: movl %esi,%esp
1.1 root 142: call _main
143: jmp 1f
144:
145: .data
146: _bootdev: .long 0
147: _cyloffset: .long 0
148: savearea: .long 0,0 # sp & bp to return to
149: .text
150: .globl _wait
151:
152: __rtt:
153: pushl $1000000
154: call _wait
155: popl %eax
156: movl $-7,%eax
157: jmp 1f
1.1.1.2 root 158:
1.1 root 159: _exit:
1.1.1.2 root 160: pushl $1000000
161: call _wait
162: popl %eax
1.1 root 163: movl 4(%esp),%eax
164: 1:
165: #ifdef REL
166: #ifndef SMALL
167: call _reset_cpu
168: #endif
169: movw $0x1234,%ax
170: movw %ax,0x472 # warm boot
171: movl $0,%esp # segment violation
172: ret
173: #else
174: movl savearea,%esp
175: movl savearea+4,%ebp
176: ret
177: #endif
178:
179: .globl _inb
180: _inb: movl 4(%esp),%edx
181: subl %eax,%eax # clr eax
1.1.1.3 ! root 182: NOP
1.1 root 183: inb %dx,%al
184: ret
185:
186: .globl _outb
187: _outb: movl 4(%esp),%edx
1.1.1.3 ! root 188: NOP
1.1 root 189: movl 8(%esp),%eax
190: outb %al,%dx
191: ret
192:
193: .globl ___udivsi3
194: ___udivsi3:
195: movl 4(%esp),%eax
196: xorl %edx,%edx
197: divl 8(%esp)
198: ret
199:
200: .globl ___divsi3
201: ___divsi3:
202: movl 4(%esp),%eax
203: xorl %edx,%edx
204: cltd
205: idivl 8(%esp)
206: ret
207:
208: #
209: # bzero (base,cnt)
210: #
211:
212: .globl _bzero
213: _bzero:
214: pushl %edi
215: movl 8(%esp),%edi
216: movl 12(%esp),%ecx
217: movb $0x00,%al
218: cld
219: rep
220: stosb
221: popl %edi
222: ret
223:
224: #
225: # bcopy (src,dst,cnt)
226: # NOTE: does not (yet) handle overlapped copies
227: #
228:
229: .globl _bcopy
230: _bcopy:
231: pushl %esi
232: pushl %edi
233: movl 12(%esp),%esi
234: movl 16(%esp),%edi
235: movl 20(%esp),%ecx
236: cld
237: rep
238: movsb
239: popl %edi
240: popl %esi
241: ret
242:
243: # insw(port,addr,cnt)
244: .globl _insw
245: _insw:
246: pushl %edi
247: movw 8(%esp),%dx
248: movl 12(%esp),%edi
249: movl 16(%esp),%ecx
1.1.1.3 ! root 250: NOP
1.1 root 251: cld
252: nop
253: .byte 0x66,0xf2,0x6d # rep insw
254: nop
255: movl %edi,%eax
256: popl %edi
257: ret
258:
259: # outsw(port,addr,cnt)
260: .globl _outsw
261: _outsw:
262: pushl %esi
263: movw 8(%esp),%dx
264: movl 12(%esp),%esi
265: movl 16(%esp),%ecx
1.1.1.3 ! root 266: NOP
1.1 root 267: cld
268: nop
269: .byte 0x66,0xf2,0x6f # rep outsw
270: nop
271: movl %esi,%eax
272: popl %esi
273: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.