xref: /haiku/src/system/boot/platform/bios_ia32/support.S (revision 922e7ba1f3228e6f28db69b0ded8f86eb32dea17)
1/*
2** Copyright 2001, Travis Geiselbrecht. All rights reserved.
3** Distributed under the terms of the NewOS License.
4*/
5
6
7#define FUNCTION(x) .global x; .type x,@function; x
8
9
10/* uint64 rdtsc() */
11FUNCTION(rdtsc):
12	rdtsc
13	ret
14
15FUNCTION(execute_n_instructions):
16	movl	4(%esp), %ecx
17	shrl	$4, %ecx
18.again:
19	xorl	%eax, %eax
20	xorl	%eax, %eax
21	xorl	%eax, %eax
22	xorl	%eax, %eax
23	xorl	%eax, %eax
24	xorl	%eax, %eax
25	xorl	%eax, %eax
26	xorl	%eax, %eax
27	xorl	%eax, %eax
28	xorl	%eax, %eax
29	xorl	%eax, %eax
30	xorl	%eax, %eax
31	xorl	%eax, %eax
32	xorl	%eax, %eax
33	xorl	%eax, %eax
34	xorl	%eax, %eax
35	loop	.again
36	ret
37
38FUNCTION(system_time):
39   	/* load 64-bit factor into %eax (low), %edx (high) */
40   	/* hand-assemble rdtsc -- read time stamp counter */
41	rdtsc		/* time in %edx,%eax */
42
43	pushl	%ebx
44	movl	gTimeConversionFactor, %ebx
45	movl	%edx, %ecx	/* save high half */
46	mull	%ebx 		/* truncate %eax, but keep %edx */
47	movl	%ecx, %eax
48	movl	%edx, %ecx	/* save high half of low */
49	mull	%ebx			/*, %eax*/
50	/* now compute  [%edx, %eax] + [%ecx], propagating carry */
51	subl	%ebx, %ebx	/* need zero to propagate carry */
52	addl	%ecx, %eax
53	adc		%ebx, %edx
54	popl	%ebx
55	ret
56
57null_idt_descr:
58	.word	0
59	.word	0,0
60
61FUNCTION(reboot):
62	lidt	null_idt_descr
63	int		$0
64done:
65	jmp		done
66
67