Deleted Added
full compact
btxldr.S (129516) btxldr.S (146011)
1/*
2 * Copyright (c) 1998 Robert Nordier
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
8 * such forms.
9 *
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
13 * purpose.
14 *
1/*
2 * Copyright (c) 1998 Robert Nordier
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
8 * such forms.
9 *
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
13 * purpose.
14 *
15 * $FreeBSD: head/sys/boot/pc98/btx/btxldr/btxldr.S 128710 2004-04-28 10:15:31Z ru $
15 * $FreeBSD: head/sys/boot/pc98/btx/btxldr/btxldr.S 146011 2005-05-08 14:17:28Z nyan $
16 */
17
18/*
19 * Prototype BTX loader program, written in a couple of hours. The
20 * real thing should probably be more flexible, and in C.
21 */
22
23/*

--- 14 unchanged lines hidden (view full) ---

38/*
39 * Paging constants.
40 */
41 .set PAG_SIZ,0x1000 # Page size
42 .set PAG_ENT,0x4 # Page entry size
43/*
44 * Screen constants.
45 */
16 */
17
18/*
19 * Prototype BTX loader program, written in a couple of hours. The
20 * real thing should probably be more flexible, and in C.
21 */
22
23/*

--- 14 unchanged lines hidden (view full) ---

38/*
39 * Paging constants.
40 */
41 .set PAG_SIZ,0x1000 # Page size
42 .set PAG_ENT,0x4 # Page entry size
43/*
44 * Screen constants.
45 */
46#ifdef PC98
47 .set SCR_MAT,0xe1 # Mode/attribute
46 .set SCR_MAT,0xe1 # Mode/attribute
48#else
49 .set SCR_MAT,0x7 # Mode/attribute
50#endif
51 .set SCR_COL,0x50 # Columns per row
52 .set SCR_ROW,0x19 # Rows per screen
53/*
54 * BIOS Data Area locations.
55 */
47 .set SCR_COL,0x50 # Columns per row
48 .set SCR_ROW,0x19 # Rows per screen
49/*
50 * BIOS Data Area locations.
51 */
56#ifdef PC98
57 .set BDA_MEM,0xa1501 # Free memory
58 .set BDA_POS,0xa153e # Cursor position
52 .set BDA_MEM,0xa1501 # Free memory
53 .set BDA_POS,0xa153e # Cursor position
59#else
60 .set BDA_MEM,0x413 # Free memory
61 .set BDA_SCR,0x449 # Video mode
62 .set BDA_POS,0x450 # Cursor position
63#endif
64/*
65 * Required by aout gas inadequacy.
66 */
67 .set SIZ_STUB,0x1a # Size of stub
68/*
69 * We expect to be loaded by boot2 at the origin defined in ./Makefile.
70 */
71 .globl start
72/*
73 * BTX program loader for ELF clients.
74 */
75start: cld # String ops inc
54/*
55 * Required by aout gas inadequacy.
56 */
57 .set SIZ_STUB,0x1a # Size of stub
58/*
59 * We expect to be loaded by boot2 at the origin defined in ./Makefile.
60 */
61 .globl start
62/*
63 * BTX program loader for ELF clients.
64 */
65start: cld # String ops inc
76#ifdef PC98
77 cli
78gdcwait.1: inb $0x60,%al
79 testb $0x04,%al
80 jz gdcwait.1
81 movb $0xe0,%al
82 outb %al,$0x62
83 nop
84gdcwait.2: inb $0x60,%al

--- 4 unchanged lines hidden (view full) ---

89 inb $0x62,%al
90 movb %al,%dh
91 inb $0x62,%al
92 inb $0x62,%al
93 inb $0x62,%al
94 shlw $1,%dx
95 movl $BDA_POS,%ebx
96 movw %dx,(%ebx)
66 cli
67gdcwait.1: inb $0x60,%al
68 testb $0x04,%al
69 jz gdcwait.1
70 movb $0xe0,%al
71 outb %al,$0x62
72 nop
73gdcwait.2: inb $0x60,%al

--- 4 unchanged lines hidden (view full) ---

78 inb $0x62,%al
79 movb %al,%dh
80 inb $0x62,%al
81 inb $0x62,%al
82 inb $0x62,%al
83 shlw $1,%dx
84 movl $BDA_POS,%ebx
85 movw %dx,(%ebx)
97#endif
98 movl $m_logo,%esi # Identify
99 call putstr # ourselves
100 movzwl BDA_MEM,%eax # Get base memory
86 movl $m_logo,%esi # Identify
87 call putstr # ourselves
88 movzwl BDA_MEM,%eax # Get base memory
101#ifdef PC98
102 andl $0x7,%eax
103 incl %eax
104 shll $0x11,%eax # in bytes
89 andl $0x7,%eax
90 incl %eax
91 shll $0x11,%eax # in bytes
105#else
106 shll $0xa,%eax # in bytes
107#endif
108 movl %eax,%ebp # Base of user stack
109#ifdef BTXLDR_VERBOSE
110 movl $m_mem,%esi # Display
111 call hexout # amount of
112 call putstr # base memory
113#endif
114 lgdt gdtdesc # Load new GDT
115/*

--- 209 unchanged lines hidden (view full) ---

325/*
326 * Output character AL to the console.
327 */
328putchr: pusha # Save
329 xorl %ecx,%ecx # Zero for loops
330 movb $SCR_MAT,%ah # Mode/attribute
331 movl $BDA_POS,%ebx # BDA pointer
332 movw (%ebx),%dx # Cursor position
92 movl %eax,%ebp # Base of user stack
93#ifdef BTXLDR_VERBOSE
94 movl $m_mem,%esi # Display
95 call hexout # amount of
96 call putstr # base memory
97#endif
98 lgdt gdtdesc # Load new GDT
99/*

--- 209 unchanged lines hidden (view full) ---

309/*
310 * Output character AL to the console.
311 */
312putchr: pusha # Save
313 xorl %ecx,%ecx # Zero for loops
314 movb $SCR_MAT,%ah # Mode/attribute
315 movl $BDA_POS,%ebx # BDA pointer
316 movw (%ebx),%dx # Cursor position
333#ifdef PC98
334 movl $0xa0000,%edi # Regen buffer (color)
317 movl $0xa0000,%edi # Regen buffer (color)
335#else
336 movl $0xb8000,%edi # Regen buffer (color)
337 cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
338 jne putchr.1 # No
339 xorw %di,%di # Regen buffer (mono)
340#endif
341putchr.1: cmpb $0xa,%al # New line?
342 je putchr.2 # Yes
318putchr.1: cmpb $0xa,%al # New line?
319 je putchr.2 # Yes
343#ifdef PC98
344 movw %dx,%cx
345 movb %al,(%edi,%ecx,1) # Write char
346 addl $0x2000,%ecx
347 movb %ah,(%edi,%ecx,1) # Write attr
348 addw $0x2,%dx
349 jmp putchr.3
350putchr.2: movw %dx,%ax
351 movb $SCR_COL*2,%dl
352 div %dl
353 incb %al
354 mul %dl
355 movw %ax,%dx
356putchr.3: cmpw $SCR_COL*SCR_ROW*2,%dx
320 movw %dx,%cx
321 movb %al,(%edi,%ecx,1) # Write char
322 addl $0x2000,%ecx
323 movb %ah,(%edi,%ecx,1) # Write attr
324 addw $0x2,%dx
325 jmp putchr.3
326putchr.2: movw %dx,%ax
327 movb $SCR_COL*2,%dl
328 div %dl
329 incb %al
330 mul %dl
331 movw %ax,%dx
332putchr.3: cmpw $SCR_COL*SCR_ROW*2,%dx
357#else
358 xchgl %eax,%ecx # Save char
359 movb $SCR_COL,%al # Columns per row
360 mulb %dh # * row position
361 addb %dl,%al # + column
362 adcb $0x0,%ah # position
363 shll %eax # * 2
364 xchgl %eax,%ecx # Swap char, offset
365 movw %ax,(%edi,%ecx,1) # Write attr:char
366 incl %edx # Bump cursor
367 cmpb $SCR_COL,%dl # Beyond row?
368 jb putchr.3 # No
369putchr.2: xorb %dl,%dl # Zero column
370 incb %dh # Bump row
371putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
372#endif
373 jb putchr.4 # No
374 leal 2*SCR_COL(%edi),%esi # New top line
375 movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
376 rep # Scroll
377 movsl # screen
378 movb $' ',%al # Space
333 jb putchr.4 # No
334 leal 2*SCR_COL(%edi),%esi # New top line
335 movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
336 rep # Scroll
337 movsl # screen
338 movb $' ',%al # Space
379#ifdef PC98
380 xorb %ah,%ah
339 xorb %ah,%ah
381#endif
382 movb $SCR_COL,%cl # Columns to clear
383 rep # Clear
384 stosw # line
340 movb $SCR_COL,%cl # Columns to clear
341 rep # Clear
342 stosw # line
385#ifdef PC98
386 movw $(SCR_ROW-1)*SCR_COL*2,%dx
387putchr.4: movw %dx,(%ebx) # Update position
388 shrw $1,%dx
389gdcwait.3: inb $0x60,%al
390 testb $0x04,%al
391 jz gdcwait.3
392 movb $0x49,%al
393 outb %al,$0x62
394 movb %dl,%al
395 outb %al,$0x60
396 movb %dh,%al
397 outb %al,$0x60
343 movw $(SCR_ROW-1)*SCR_COL*2,%dx
344putchr.4: movw %dx,(%ebx) # Update position
345 shrw $1,%dx
346gdcwait.3: inb $0x60,%al
347 testb $0x04,%al
348 jz gdcwait.3
349 movb $0x49,%al
350 outb %al,$0x62
351 movb %dl,%al
352 outb %al,$0x60
353 movb %dh,%al
354 outb %al,$0x60
398#else
399 movb $SCR_ROW-1,%dh # Bottom line
400putchr.4: movw %dx,(%ebx) # Update position
401#endif
402 popa # Restore
403 ret # To caller
404/*
405 * Convert EAX, AX, or AL to hex, saving the result to [EDI].
406 */
407hex32: pushl %eax # Save
408 shrl $0x10,%eax # Do upper
409 call hex16 # 16

--- 62 unchanged lines hidden ---
355 popa # Restore
356 ret # To caller
357/*
358 * Convert EAX, AX, or AL to hex, saving the result to [EDI].
359 */
360hex32: pushl %eax # Save
361 shrl $0x10,%eax # Do upper
362 call hex16 # 16

--- 62 unchanged lines hidden ---