[FREELDR]

convert i386pnp.S to intel sytax

svn path=/trunk/; revision=52291
This commit is contained in:
Timo Kreuzer 2011-06-17 07:53:56 +00:00
parent 7c321b081b
commit 285734917e

View file

@ -17,11 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
.text #include <asm.inc>
.code16
#include <arch/pc/x86common.h> #include <arch/pc/x86common.h>
.code32
/* /*
@ -34,68 +33,68 @@ _pnp_bios_entry_point:
_pnp_bios_data_segment: _pnp_bios_data_segment:
.word 0 .word 0
EXTERN(_PnpBiosSupported) PUBLIC _PnpBiosSupported
.code32 _PnpBiosSupported:
pushl %edi push edi
pushl %esi push esi
pushl %ecx push ecx
pushl %edx push edx
xorl %edi,%edi xor edi, edi
/* init esi */ /* init esi */
movl $0xF0000,%esi mov esi, HEX(0F0000)
pnp_again: pnp_again:
movl (%esi),%eax mov eax, [esi]
cmp $0x506E5024,%eax /* "$PnP" */ cmp eax, HEX(506E5024) /* "$PnP" */
je pnp_found je pnp_found
cmp $0xFFFF0,%esi cmp esi, HEX(0FFFF0)
je pnp_not_found je pnp_not_found
pnp_add: pnp_add:
addl $0x10,%esi add esi, 16
jmp pnp_again jmp pnp_again
pnp_found: pnp_found:
/* first calculate the checksum */ /* first calculate the checksum */
pushl %esi push esi
pushl $0x21 push HEX(21)
popl %ecx pop ecx
xorl %edx, %edx xor edx, edx
pnp_loop: pnp_loop:
lodsb lodsb
addb %al,%dl add dl, al
loopl pnp_loop loop pnp_loop
testb %dl, %dl test dl, dl
popl %esi pop esi
jnz pnp_add jnz pnp_add
movl %esi,%edi mov edi, esi
/* Calculate the bios entry point (far pointer) */ /* Calculate the bios entry point (far pointer) */
xorl %eax,%eax xor eax, eax
movw 0x0F(%esi),%ax mov ax, [esi + 15]
shll $16,%eax shl eax, 16
movw 0x0D(%esi),%ax mov ax, [esi + 0x0D]
movl %eax,_pnp_bios_entry_point mov _pnp_bios_entry_point, eax
/* Store bios data segment */ /* Store bios data segment */
movw 0x1B(%esi),%ax mov ax, [esi + 0x1B]
movw %ax,_pnp_bios_data_segment mov _pnp_bios_data_segment, ax
pnp_not_found: pnp_not_found:
movl %edi,%eax mov eax, edi
popl %edx pop edx
popl %ecx pop ecx
popl %esi pop esi
popl %edi pop edi
ret ret
@ -112,58 +111,58 @@ _pnp_node_size:
_pnp_node_count: _pnp_node_count:
.word 0 .word 0
EXTERN(_PnpBiosGetDeviceNodeCount) PUBLIC _PnpBiosGetDeviceNodeCount
.code32 _PnpBiosGetDeviceNodeCount:
pushl %ebp push ebp
movl %esp,%ebp mov ebp, esp
pushal pusha
push %es push es
call switch_to_real call switch_to_real
.code16 .code16
movw _pnp_bios_data_segment,%ax mov ax, word ptr [_pnp_bios_data_segment]
pushw %ax push ax
pushw %cs push cs
movw $(_pnp_node_size),%ax mov ax, offset _pnp_node_size
pushw %ax push ax
pushw %cs push cs
movw $(_pnp_node_count),%ax mov ax, offset _pnp_node_count
pushw %ax push ax
pushw $0 push 0
lcall *_pnp_bios_entry_point call dword ptr [_pnp_bios_entry_point]
addw $12,%sp add sp, 12
movzwl %ax,%ecx movzx ecx, ax
movl %ecx,_pnp_result mov _pnp_result, ecx
call switch_to_prot call switch_to_prot
.code32 .code32
movl 0x08(%ebp),%esi mov esi, [ebp + 8]
movw _pnp_node_size,%ax mov ax, _pnp_node_size
movzwl %ax,%ecx movzx ecx, ax
movl %ecx, (%esi) mov [esi], ecx
movl 0x0C(%ebp),%esi mov esi, [ebp + 12]
movw _pnp_node_count,%ax mov ax, _pnp_node_count
movzwl %ax,%ecx movzx ecx, ax
movl %eax, (%esi) mov [esi], eax
pop %es pop es
popal popa
movl %ebp,%esp mov esp, ebp
popl %ebp pop ebp
movl _pnp_result,%eax mov eax, _pnp_result
ret ret
@ -184,72 +183,72 @@ _pnp_node_number:
EXTERN(_PnpBiosGetDeviceNode) EXTERN(_PnpBiosGetDeviceNode)
.code32 .code32
pushl %ebp push ebp
movl %esp,%ebp mov ebp, esp
pushal pusha
push %es push es
/* get current node number */ /* get current node number */
movl 0x08(%ebp),%esi mov esi, [ebp + 8]
movb (%esi),%al mov al, [esi]
movb %al,_pnp_node_number mov _pnp_node_number, al
/* convert pointer to node buffer to segment/offset */ /* convert pointer to node buffer to segment/offset */
movl 0x0C(%ebp),%eax mov eax, [ebp + 12]
shrl $4,%eax shr eax, 4
andl $0xf000,%eax and eax, 0xf000
movw %ax,_pnp_buffer_segment mov _pnp_buffer_segment, ax
movl 0x0C(%ebp),%eax mov eax, [ebp + 12]
andl $0xffff,%eax and eax, 0xffff
movw %ax,_pnp_buffer_offset mov _pnp_buffer_offset, ax
call switch_to_real call switch_to_real
.code16 .code16
/* push bios segment */ /* push bios segment */
movw _pnp_bios_data_segment,%ax mov ax, word ptr [_pnp_bios_data_segment]
pushw %ax push ax
/* push control flag */ /* push control flag */
pushw $0x0001 push 1
/* push pointer to node buffer (segment/offset) */ /* push pointer to node buffer (segment/offset) */
movw _pnp_buffer_segment,%ax mov ax, word ptr [_pnp_buffer_segment]
pushw %ax push ax
movw _pnp_buffer_offset,%ax mov ax, word ptr [_pnp_buffer_offset]
pushw %ax push ax
/* push pointer to node number (segment/offset) */ /* push pointer to node number (segment/offset) */
pushw %cs push cs
movw $(_pnp_node_number),%ax mov ax, offset _pnp_node_number
pushw %ax push ax
/* push function number */ /* push function number */
pushw $1 push 1
/* call entry point */ /* call entry point */
lcall *_pnp_bios_entry_point call dword ptr [_pnp_bios_entry_point]
addw $14,%sp add sp, 14
movzwl %ax,%ecx movzx ecx, ax
movl %ecx,_pnp_result mov _pnp_result, ecx
call switch_to_prot call switch_to_prot
.code32 .code32
/* update node number */ /* update node number */
movl 0x08(%ebp),%esi mov esi, [ebp + 8]
movb _pnp_node_number,%al mov al, _pnp_node_number
movb %al,(%esi) mov [esi], al
pop %es pop es
popal popa
movl %ebp,%esp mov esp, ebp
popl %ebp pop ebp
movl _pnp_result,%eax mov eax, _pnp_result
ret ret