Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 316 → Rev 315

/SPARTAN/trunk/arch/ia32/src/asm.S
54,12 → 54,14
# Enable paging and write-back caching in CR0.
#
paging_on:
movl %cr0,%edx
orl $(1<<31),%edx # paging on
andl $~((1<<30)|(1<<29)),%edx # clear Cache Disable and not Write Though
movl %edx,%cr0
pushl %eax
movl %cr0,%eax
orl $(1<<31),%eax # paging on
andl $~((1<<30)|(1<<29)),%eax # clear Cache Disable and not Write Though
movl %eax,%cr0
jmp 0f
0:
popl %eax
ret
 
 
68,15 → 70,15
# Enable local APIC in MSR.
#
enable_l_apic_in_msr:
push %eax
 
pusha
movl $0x1b, %ecx
rdmsr
orl $(1<<11),%eax
orl $(0xfee00000),%eax
wrmsr
 
pop %eax
popa
ret
 
 
113,30 → 115,30
 
 
# CLNT
pushfl
pop %eax
and $0xFFFFBFFF,%eax
push %eax
popfl
pushfl;
pop %eax;
and $0xFFFFBFFF,%eax;
push %eax;
popfl;
 
 
# Test if this is interrupt with error word or not
mov $\i,%cl
movl $1,%eax
test $0xe0,%cl
jnz 0f
and $0x1f,%cl
shl %cl,%eax
and $ERROR_WORD_INTERRUPT_LIST,%eax
jz 0f
mov $\i,%cl;
movl $1,%eax;
test $0xe0,%cl;
jnz 0f;
and $0x1f,%cl;
shl %cl,%eax;
and $ERROR_WORD_INTERRUPT_LIST,%eax;
jz 0f;
 
 
# Return with error word
popa
pop %ebp
add $4,%esp # Skip error word
iret
popa;
pop %ebp;
add $4,%esp; # Skip error word
iret;
 
0:
# Return with no error word
165,9 → 167,11
# Get a byte from I/O port and store it AL.
#
inb:
push %edx
xorl %eax,%eax
movl 4(%esp),%edx
movl 8(%esp),%edx
inb %dx,%al
pop %edx
ret
 
 
176,9 → 180,11
# Get a word from I/O port and store it AX.
#
inw:
push %edx
xorl %eax,%eax
movl 4(%esp),%edx
movl 8(%esp),%edx
inw %dx,%ax
pop %edx
ret
 
 
187,9 → 193,11
# Get a dword from I/O port and store it EAX.
#
inl:
push %edx
xorl %eax,%eax
movl 4(%esp),%edx
movl 8(%esp),%edx
inl %dx,%eax
pop %edx
ret
 
 
198,13 → 206,16
# Send a byte to I/O port.
#
outb:
push %eax
push %ebp
movl %esp,%ebp
pusha
 
movl 8(%esp),%edx
movl 12(%esp),%eax
movl 8(%ebp),%edx
movl 12(%ebp),%eax
outb %al,%dx
 
pop %eax
popa
pop %ebp
ret
 
 
213,13 → 224,16
# Send a word to I/O port.
#
outw:
push %eax
push %ebp
movl %esp,%ebp
pusha
 
movl 8(%esp),%edx
movl 12(%esp),%eax
movl 8(%ebp),%edx
movl 12(%ebp),%eax
outw %ax,%dx
 
pop %eax
popa
pop %ebp
ret
 
 
228,13 → 242,16
# Send a dword to I/O port.
#
outl:
push %eax
push %ebp
movl %esp,%ebp
pusha
 
movl 8(%esp),%edx
movl 12(%esp),%eax
movl 8(%ebp),%edx
movl 12(%ebp),%eax
outl %eax,%dx
 
pop %eax
popa
pop %ebp
ret
 
 
245,21 → 262,23
# to the memory location defined by 1st argument.
# The memory areas cannot overlap.
#
SRC=16
DST=12
CNT=20
SRC=12
DST=8
CNT=16
memcpy:
push %esi
push %edi
push %ebp
movl %esp,%ebp
pusha
 
movl CNT(%esp),%ecx
movl DST(%esp),%edi
movl SRC(%esp),%esi
cld
movl CNT(%ebp),%ecx
movl DST(%ebp),%edi
movl SRC(%ebp),%esi
 
rep movsb %ds:(%esi),%es:(%edi)
 
pop %edi
pop %esi
popa
pop %ebp
ret
 
 
269,21 → 288,23
# at memory defined by 1st argument with the
# byte value defined by 3rd argument.
#
DST=12
CNT=16
X=20
DST=8
CNT=12
X=16
memsetb:
push %eax
push %edi
push %ebp
movl %esp,%ebp
pusha
 
movl CNT(%esp),%ecx
movl DST(%esp),%edi
movl X(%esp),%eax
cld
movl CNT(%ebp),%ecx
movl DST(%ebp),%edi
movl X(%ebp),%eax
 
rep stosb %al,%es:(%edi)
 
pop %edi
pop %eax
popa
pop %ebp
ret
 
 
293,22 → 314,23
# at memory defined by 1st argument with the
# word value defined by 3rd argument.
#
DST=12
CNT=16
X=20
DST=8
CNT=12
X=16
memsetw:
push %eax
push %edi
push %ebp
movl %esp,%ebp
pusha
 
movl CNT(%esp),%ecx
movl DST(%esp),%edi
movl X(%esp),%eax
cld
movl CNT(%ebp),%ecx
movl DST(%ebp),%edi
movl X(%ebp),%eax
 
rep stosw %ax,%es:(%edi)
 
pop %edi
pop %eax
 
popa
pop %ebp
ret
 
 
323,19 → 345,26
DST=16
CNT=20
memcmp:
push %esi
push %edi
push %ebp
subl $4,%esp
movl %esp,%ebp
 
movl CNT(%esp),%ecx
movl DST(%esp),%edi
movl SRC(%esp),%esi
pusha
 
cld
movl CNT(%ebp),%ecx
movl DST(%ebp),%edi
movl SRC(%ebp),%esi
 
repe cmpsb %es:(%edi),%ds:(%esi)
movl %ecx,%eax # %ecx contains the return value (zero on success)
movl %ecx,(%ebp)
 
pop %edi
pop %esi
popa
movl (%ebp),%eax # return value => %eax (zero on success)
addl $4,%esp
pop %ebp
ret
 
 
342,11 → 371,11
# THIS IS USERSPACE CODE
.global utext
utext:
xor %ax,%ax
mov %ax,%ds
mov %ax,%es
mov %ax,%fs
mov %ax,%gs
xor %ax,%ax;
mov %ax,%ds;
mov %ax,%es;
mov %ax,%fs;
mov %ax,%gs;
0:
int $48
jmp 0b