- int $0x00
- pushf
- data32
- addr32
- movl %eax, save_eax
- popl %eax // actually pop %ax
- addr32
- movl %eax, save_flag // actually movw
- mov %es, %ax
- addr32
- movl %eax, save_es // actually movw
- data32
- call EXT(_real_to_prot)
-
- movl %edx, new_edx // save new edx before clobbering
- movl save_edx, %edx
- movl new_edx, %eax // now move it into buffer
- movl %eax, O_EDX(%edx)
- movl save_eax, %eax
- movl %eax, O_EAX(%edx)
- movw save_es, %ax
- movw %ax, O_ES(%edx)
- movw save_flag, %ax
- movw %ax, O_FLG(%edx)
- movl %ebx, O_EBX(%edx)
- movl %ecx, O_ECX(%edx)
- movl %edi, O_EDI(%edx)
- movl %esi, O_ESI(%edx)
- movl %ebp, O_EBP(%edx)
-
- popal
- leave
-
- ret
-
-/*============================================================================
- * Determines the total system memory size using various BIOS Int 15 calls.
- *
- */
-ENTRY(get_memsize)
- enter $0, $0 # create frame pointer (32 bit operand/stack)
- pushal # save all registers
-
- movl 8(%ebp), %ebx # push input structure pointer to stack
- pushl %ebx
-
- call EXT(_prot_to_real) # switch to real mode
-
- ##################################################################
- # In real mode.
- # Do not forget the opcode overrides, since the assembler
- # does not know we have made a transition to 16-bit operation.
- ##################################################################
-
- data32
- movl $0xE801, %eax # Get memory size
- clc
- int $0x15
- data32
- jnc getmsz_e801
-
- data32
- movl $0xDA88, %eax # Get memory size
- clc
- int $0x15
- data32
- jnc getmsz_da88
-
- movb $0x8A, %ah # Get memory size
- clc
- int $0x15
- data32
- jnc getmsz_8a
-
- movb $0x88, %ah # Get memory size
- clc
- int $0x15
- data32
- jnc getmsz_88
-
- xorl %edx, %edx # Error, cannot get memory size
- xorl %eax, %eax
-
-getmsz_done:
- data32
- addr32
- pushl %eax # Push EAX to 32-bit stack
-
- data32
- call EXT(_real_to_prot) # Back to protected mode. EAX is modified.
-
- ##################################################################
- # Back to protected mode.
- ##################################################################
-
- popl %eax # Pop EAX from stack
- popl %ebx # Pop pointer to register structure
-
- # Copy the result to the input structure pointed to by a pointer
- # which is on top of the stack. Write register EAX and EDX to the
- # structure.
-
- movl %eax, O_EAX(%ebx)
- movl %edx, O_EDX(%ebx)
-
- popal # restore all registers
- leave # undo enter operator
- ret
-
-getmsz_88:
- orl %eax, %eax
- data32
- jz getmsz_64m
- xorl %edx, %edx
-
-getmsz_8a:
- data32
- movl $1024, %ebx # Add in 1M
- addl %ebx, %eax
- adcl $0, %edx
- data32
- jmp getmsz_done
-
-getmsz_64m:
- data32
- movl $1, %edx
- xorl %eax, %eax
- data32
- jmp getmsz_done
-
-getmsz_da88:
- xor %dh, %dh
- movb %cl, %dl
- movl %ebx, %eax
- data32
- jmp getmsz_8a
-
-getmsz_e801:
- xorl %edx, %edx
- orl %ebx, %ebx
- data32
- jz getmsz_88
-
- data32
- movl $64, %eax
- mul %ebx
-
- data32
- movl $16384, %ebx
- addl %ebx, %eax
- adcl $0, %edx
-
- data32
- jmp getmsz_done
+ int $0x00
+ pushf
+ data32
+ addr32
+ movl %eax, OFFSET16(save_eax)
+ popl %eax // actually pop %ax
+ addr32
+ movl %eax, OFFSET16(save_flag) // actually movw
+ mov %es, %ax
+ addr32
+ movl %eax, OFFSET16(save_es) // actually movw
+ data32
+ call __real_to_prot
+
+ movl %edx, new_edx // save new edx before clobbering
+ movl save_edx, %edx
+ movl new_edx, %eax // now move it into buffer
+ movl %eax, O_EDX(%edx)
+ movl save_eax, %eax
+ movl %eax, O_EAX(%edx)
+ movw save_es, %ax
+ movw %ax, O_ES(%edx)
+ movw save_flag, %ax
+ movw %ax, O_FLG(%edx)
+ movl %ebx, O_EBX(%edx)
+ movl %ecx, O_ECX(%edx)
+ movl %edi, O_EDI(%edx)
+ movl %esi, O_ESI(%edx)
+ movl %ebp, O_EBP(%edx)
+
+ popal
+ leave
+
+ ret