Home | History | Annotate | Line # | Download | only in apps
tcc.c revision 1.1.1.1.10.2
      1  1.1.1.1.10.2  tls /*	$NetBSD: tcc.c,v 1.1.1.1.10.2 2014/08/20 00:04:23 tls Exp $	*/
      2  1.1.1.1.10.2  tls 
      3  1.1.1.1.10.2  tls /*
      4  1.1.1.1.10.2  tls  * Test if our calling convention gymnastics actually work
      5  1.1.1.1.10.2  tls  */
      6  1.1.1.1.10.2  tls 
      7  1.1.1.1.10.2  tls #include <efi.h>
      8  1.1.1.1.10.2  tls #include <efilib.h>
      9  1.1.1.1.10.2  tls 
     10  1.1.1.1.10.2  tls #ifdef __x86_64__
     11  1.1.1.1.10.2  tls #include <x86_64/pe.h>
     12  1.1.1.1.10.2  tls #include <x86_64/efibind.h>
     13  1.1.1.1.10.2  tls #endif
     14  1.1.1.1.10.2  tls 
     15  1.1.1.1.10.2  tls #if 0
     16  1.1.1.1.10.2  tls 	asm volatile("out %0,%1" : : "a" ((uint8_t)a), "dN" (0x80));
     17  1.1.1.1.10.2  tls 
     18  1.1.1.1.10.2  tls extern void dump_stack(void);
     19  1.1.1.1.10.2  tls asm(	".globl	dump_stack\n"
     20  1.1.1.1.10.2  tls 	"dump_stack:\n"
     21  1.1.1.1.10.2  tls 	"	movq %rsp, %rdi\n"
     22  1.1.1.1.10.2  tls 	"	jmp *dump_stack_helper@GOTPCREL(%rip)\n"
     23  1.1.1.1.10.2  tls 	".size	dump_stack, .-dump_stack");
     24  1.1.1.1.10.2  tls 
     25  1.1.1.1.10.2  tls void dump_stack_helper(uint64_t rsp_val)
     26  1.1.1.1.10.2  tls {
     27  1.1.1.1.10.2  tls 	uint64_t *rsp = (uint64_t *)rsp_val;
     28  1.1.1.1.10.2  tls 	int x;
     29  1.1.1.1.10.2  tls 
     30  1.1.1.1.10.2  tls 	Print(L"%%rsp: 0x%08x%08x stack:\r\n",
     31  1.1.1.1.10.2  tls 					(rsp_val & 0xffffffff00000000) >>32,
     32  1.1.1.1.10.2  tls 					 rsp_val & 0xffffffff);
     33  1.1.1.1.10.2  tls 	for (x = 0; x < 8; x++) {
     34  1.1.1.1.10.2  tls 		Print(L"%08x: ", ((uint64_t)rsp) & 0xffffffff);
     35  1.1.1.1.10.2  tls 		Print(L"%016x ", *rsp++);
     36  1.1.1.1.10.2  tls 		Print(L"%016x ", *rsp++);
     37  1.1.1.1.10.2  tls 		Print(L"%016x ", *rsp++);
     38  1.1.1.1.10.2  tls 		Print(L"%016x\r\n", *rsp++);
     39  1.1.1.1.10.2  tls 	}
     40  1.1.1.1.10.2  tls }
     41  1.1.1.1.10.2  tls #endif
     42  1.1.1.1.10.2  tls 
     43  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_failure_callback(void)
     44  1.1.1.1.10.2  tls {
     45  1.1.1.1.10.2  tls 	return EFI_UNSUPPORTED;
     46  1.1.1.1.10.2  tls }
     47  1.1.1.1.10.2  tls 
     48  1.1.1.1.10.2  tls EFI_STATUS test_failure(void)
     49  1.1.1.1.10.2  tls {
     50  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_failure_callback, 0);
     51  1.1.1.1.10.2  tls }
     52  1.1.1.1.10.2  tls 
     53  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call0_callback(void)
     54  1.1.1.1.10.2  tls {
     55  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
     56  1.1.1.1.10.2  tls }
     57  1.1.1.1.10.2  tls 
     58  1.1.1.1.10.2  tls EFI_STATUS test_call0(void)
     59  1.1.1.1.10.2  tls {
     60  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call0_callback, 0);
     61  1.1.1.1.10.2  tls }
     62  1.1.1.1.10.2  tls 
     63  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call1_callback(UINT32 a)
     64  1.1.1.1.10.2  tls {
     65  1.1.1.1.10.2  tls 	if (a != 0x12345678) {
     66  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
     67  1.1.1.1.10.2  tls 	}
     68  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
     69  1.1.1.1.10.2  tls }
     70  1.1.1.1.10.2  tls 
     71  1.1.1.1.10.2  tls EFI_STATUS test_call1(void)
     72  1.1.1.1.10.2  tls {
     73  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call1_callback, 1,0x12345678);
     74  1.1.1.1.10.2  tls }
     75  1.1.1.1.10.2  tls 
     76  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call2_callback(UINT32 a, UINT32 b)
     77  1.1.1.1.10.2  tls {
     78  1.1.1.1.10.2  tls 	if (a != 0x12345678) {
     79  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
     80  1.1.1.1.10.2  tls 	}
     81  1.1.1.1.10.2  tls 	if (b != 0x23456789) {
     82  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
     83  1.1.1.1.10.2  tls 	}
     84  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
     85  1.1.1.1.10.2  tls }
     86  1.1.1.1.10.2  tls 
     87  1.1.1.1.10.2  tls EFI_STATUS test_call2(void)
     88  1.1.1.1.10.2  tls {
     89  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call2_callback, 2,
     90  1.1.1.1.10.2  tls 		0x12345678, 0x23456789);
     91  1.1.1.1.10.2  tls }
     92  1.1.1.1.10.2  tls 
     93  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call3_callback(UINT32 a, UINT32 b,
     94  1.1.1.1.10.2  tls 	UINT32 c)
     95  1.1.1.1.10.2  tls {
     96  1.1.1.1.10.2  tls 	if (a != 0x12345678)
     97  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
     98  1.1.1.1.10.2  tls 	if (b != 0x23456789)
     99  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
    100  1.1.1.1.10.2  tls 	if (c != 0x3456789a)
    101  1.1.1.1.10.2  tls 		return EFI_UNSUPPORTED;
    102  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
    103  1.1.1.1.10.2  tls }
    104  1.1.1.1.10.2  tls 
    105  1.1.1.1.10.2  tls EFI_STATUS test_call3(void)
    106  1.1.1.1.10.2  tls {
    107  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call3_callback, 3,
    108  1.1.1.1.10.2  tls 		0x12345678, 0x23456789, 0x3456789a);
    109  1.1.1.1.10.2  tls }
    110  1.1.1.1.10.2  tls 
    111  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call4_callback(UINT32 a, UINT32 b,
    112  1.1.1.1.10.2  tls 	UINT32 c, UINT32 d)
    113  1.1.1.1.10.2  tls {
    114  1.1.1.1.10.2  tls 	if (a != 0x12345678)
    115  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
    116  1.1.1.1.10.2  tls 	if (b != 0x23456789)
    117  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
    118  1.1.1.1.10.2  tls 	if (c != 0x3456789a)
    119  1.1.1.1.10.2  tls 		return EFI_UNSUPPORTED;
    120  1.1.1.1.10.2  tls 	if (d != 0x456789ab)
    121  1.1.1.1.10.2  tls 		return EFI_BAD_BUFFER_SIZE;
    122  1.1.1.1.10.2  tls 
    123  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
    124  1.1.1.1.10.2  tls }
    125  1.1.1.1.10.2  tls 
    126  1.1.1.1.10.2  tls EFI_STATUS test_call4(void)
    127  1.1.1.1.10.2  tls {
    128  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call4_callback, 4,
    129  1.1.1.1.10.2  tls 		0x12345678, 0x23456789, 0x3456789a, 0x456789ab);
    130  1.1.1.1.10.2  tls }
    131  1.1.1.1.10.2  tls 
    132  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call5_callback(UINT32 a, UINT32 b,
    133  1.1.1.1.10.2  tls 	UINT32 c, UINT32 d, UINT32 e)
    134  1.1.1.1.10.2  tls {
    135  1.1.1.1.10.2  tls 	if (a != 0x12345678)
    136  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
    137  1.1.1.1.10.2  tls 	if (b != 0x23456789)
    138  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
    139  1.1.1.1.10.2  tls 	if (c != 0x3456789a)
    140  1.1.1.1.10.2  tls 		return EFI_UNSUPPORTED;
    141  1.1.1.1.10.2  tls 	if (d != 0x456789ab)
    142  1.1.1.1.10.2  tls 		return EFI_BAD_BUFFER_SIZE;
    143  1.1.1.1.10.2  tls 	if (e != 0x56789abc)
    144  1.1.1.1.10.2  tls 		return EFI_BUFFER_TOO_SMALL;
    145  1.1.1.1.10.2  tls 
    146  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
    147  1.1.1.1.10.2  tls }
    148  1.1.1.1.10.2  tls 
    149  1.1.1.1.10.2  tls EFI_STATUS test_call5(void)
    150  1.1.1.1.10.2  tls {
    151  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call5_callback, 5,
    152  1.1.1.1.10.2  tls 		0x12345678, 0x23456789, 0x3456789a, 0x456789ab, 0x56789abc);
    153  1.1.1.1.10.2  tls }
    154  1.1.1.1.10.2  tls 
    155  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call6_callback(UINT32 a, UINT32 b,
    156  1.1.1.1.10.2  tls 	UINT32 c, UINT32 d, UINT32 e, UINT32 f)
    157  1.1.1.1.10.2  tls {
    158  1.1.1.1.10.2  tls 	if (a != 0x12345678)
    159  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
    160  1.1.1.1.10.2  tls 	if (b != 0x23456789)
    161  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
    162  1.1.1.1.10.2  tls 	if (c != 0x3456789a)
    163  1.1.1.1.10.2  tls 		return EFI_UNSUPPORTED;
    164  1.1.1.1.10.2  tls 	if (d != 0x456789ab)
    165  1.1.1.1.10.2  tls 		return EFI_BAD_BUFFER_SIZE;
    166  1.1.1.1.10.2  tls 	if (e != 0x56789abc)
    167  1.1.1.1.10.2  tls 		return EFI_BUFFER_TOO_SMALL;
    168  1.1.1.1.10.2  tls 	if (f != 0x6789abcd)
    169  1.1.1.1.10.2  tls 		return EFI_NOT_READY;
    170  1.1.1.1.10.2  tls 
    171  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
    172  1.1.1.1.10.2  tls }
    173  1.1.1.1.10.2  tls 
    174  1.1.1.1.10.2  tls EFI_STATUS test_call6(void)
    175  1.1.1.1.10.2  tls {
    176  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call6_callback, 6,
    177  1.1.1.1.10.2  tls 		0x12345678, 0x23456789, 0x3456789a, 0x456789ab, 0x56789abc,
    178  1.1.1.1.10.2  tls 		0x6789abcd);
    179  1.1.1.1.10.2  tls }
    180  1.1.1.1.10.2  tls 
    181  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call7_callback(UINT32 a, UINT32 b,
    182  1.1.1.1.10.2  tls 	UINT32 c, UINT32 d, UINT32 e, UINT32 f, UINT32 g)
    183  1.1.1.1.10.2  tls {
    184  1.1.1.1.10.2  tls 	if (a != 0x12345678)
    185  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
    186  1.1.1.1.10.2  tls 	if (b != 0x23456789)
    187  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
    188  1.1.1.1.10.2  tls 	if (c != 0x3456789a)
    189  1.1.1.1.10.2  tls 		return EFI_UNSUPPORTED;
    190  1.1.1.1.10.2  tls 	if (d != 0x456789ab)
    191  1.1.1.1.10.2  tls 		return EFI_BAD_BUFFER_SIZE;
    192  1.1.1.1.10.2  tls 	if (e != 0x56789abc)
    193  1.1.1.1.10.2  tls 		return EFI_BUFFER_TOO_SMALL;
    194  1.1.1.1.10.2  tls 	if (f != 0x6789abcd)
    195  1.1.1.1.10.2  tls 		return EFI_NOT_READY;
    196  1.1.1.1.10.2  tls 	if (g != 0x789abcde)
    197  1.1.1.1.10.2  tls 		return EFI_DEVICE_ERROR;
    198  1.1.1.1.10.2  tls 
    199  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
    200  1.1.1.1.10.2  tls }
    201  1.1.1.1.10.2  tls 
    202  1.1.1.1.10.2  tls EFI_STATUS test_call7(void)
    203  1.1.1.1.10.2  tls {
    204  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call7_callback, 7,
    205  1.1.1.1.10.2  tls 		0x12345678, 0x23456789, 0x3456789a, 0x456789ab,
    206  1.1.1.1.10.2  tls 		0x56789abc, 0x6789abcd, 0x789abcde);
    207  1.1.1.1.10.2  tls }
    208  1.1.1.1.10.2  tls 
    209  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call8_callback(UINT32 a, UINT32 b,
    210  1.1.1.1.10.2  tls 	UINT32 c, UINT32 d, UINT32 e, UINT32 f, UINT32 g, UINT32 h)
    211  1.1.1.1.10.2  tls {
    212  1.1.1.1.10.2  tls 	if (a != 0x12345678)
    213  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
    214  1.1.1.1.10.2  tls 	if (b != 0x23456789)
    215  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
    216  1.1.1.1.10.2  tls 	if (c != 0x3456789a)
    217  1.1.1.1.10.2  tls 		return EFI_UNSUPPORTED;
    218  1.1.1.1.10.2  tls 	if (d != 0x456789ab)
    219  1.1.1.1.10.2  tls 		return EFI_BAD_BUFFER_SIZE;
    220  1.1.1.1.10.2  tls 	if (e != 0x56789abc)
    221  1.1.1.1.10.2  tls 		return EFI_BUFFER_TOO_SMALL;
    222  1.1.1.1.10.2  tls 	if (f != 0x6789abcd)
    223  1.1.1.1.10.2  tls 		return EFI_NOT_READY;
    224  1.1.1.1.10.2  tls 	if (g != 0x789abcde)
    225  1.1.1.1.10.2  tls 		return EFI_DEVICE_ERROR;
    226  1.1.1.1.10.2  tls 	if (h != 0x89abcdef)
    227  1.1.1.1.10.2  tls 		return EFI_WRITE_PROTECTED;
    228  1.1.1.1.10.2  tls 
    229  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
    230  1.1.1.1.10.2  tls }
    231  1.1.1.1.10.2  tls 
    232  1.1.1.1.10.2  tls EFI_STATUS test_call8(void)
    233  1.1.1.1.10.2  tls {
    234  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call8_callback, 8,
    235  1.1.1.1.10.2  tls 		0x12345678,
    236  1.1.1.1.10.2  tls 		0x23456789,
    237  1.1.1.1.10.2  tls 		0x3456789a,
    238  1.1.1.1.10.2  tls 		0x456789ab,
    239  1.1.1.1.10.2  tls 		0x56789abc,
    240  1.1.1.1.10.2  tls 		0x6789abcd,
    241  1.1.1.1.10.2  tls 		0x789abcde,
    242  1.1.1.1.10.2  tls 		0x89abcdef);
    243  1.1.1.1.10.2  tls }
    244  1.1.1.1.10.2  tls 
    245  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call9_callback(UINT32 a, UINT32 b,
    246  1.1.1.1.10.2  tls 	UINT32 c, UINT32 d, UINT32 e, UINT32 f, UINT32 g, UINT32 h, UINT32 i)
    247  1.1.1.1.10.2  tls {
    248  1.1.1.1.10.2  tls 	if (a != 0x12345678)
    249  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
    250  1.1.1.1.10.2  tls 	if (b != 0x23456789)
    251  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
    252  1.1.1.1.10.2  tls 	if (c != 0x3456789a)
    253  1.1.1.1.10.2  tls 		return EFI_UNSUPPORTED;
    254  1.1.1.1.10.2  tls 	if (d != 0x456789ab)
    255  1.1.1.1.10.2  tls 		return EFI_BAD_BUFFER_SIZE;
    256  1.1.1.1.10.2  tls 	if (e != 0x56789abc)
    257  1.1.1.1.10.2  tls 		return EFI_BUFFER_TOO_SMALL;
    258  1.1.1.1.10.2  tls 	if (f != 0x6789abcd)
    259  1.1.1.1.10.2  tls 		return EFI_NOT_READY;
    260  1.1.1.1.10.2  tls 	if (g != 0x789abcde)
    261  1.1.1.1.10.2  tls 		return EFI_DEVICE_ERROR;
    262  1.1.1.1.10.2  tls 	if (h != 0x89abcdef)
    263  1.1.1.1.10.2  tls 		return EFI_WRITE_PROTECTED;
    264  1.1.1.1.10.2  tls 	if (i != 0x9abcdef0)
    265  1.1.1.1.10.2  tls 		return EFI_OUT_OF_RESOURCES;
    266  1.1.1.1.10.2  tls 
    267  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
    268  1.1.1.1.10.2  tls }
    269  1.1.1.1.10.2  tls 
    270  1.1.1.1.10.2  tls EFI_STATUS test_call9(void)
    271  1.1.1.1.10.2  tls {
    272  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call9_callback, 9,
    273  1.1.1.1.10.2  tls 		0x12345678,
    274  1.1.1.1.10.2  tls 		0x23456789,
    275  1.1.1.1.10.2  tls 		0x3456789a,
    276  1.1.1.1.10.2  tls 		0x456789ab,
    277  1.1.1.1.10.2  tls 		0x56789abc,
    278  1.1.1.1.10.2  tls 		0x6789abcd,
    279  1.1.1.1.10.2  tls 		0x789abcde,
    280  1.1.1.1.10.2  tls 		0x89abcdef,
    281  1.1.1.1.10.2  tls 		0x9abcdef0);
    282  1.1.1.1.10.2  tls }
    283  1.1.1.1.10.2  tls 
    284  1.1.1.1.10.2  tls extern EFI_STATUS test_call10(void);
    285  1.1.1.1.10.2  tls EFI_STATUS EFI_FUNCTION test_call10_callback(UINT32 a, UINT32 b,
    286  1.1.1.1.10.2  tls 	UINT32 c, UINT32 d, UINT32 e, UINT32 f, UINT32 g, UINT32 h, UINT32 i,
    287  1.1.1.1.10.2  tls 	UINT32 j)
    288  1.1.1.1.10.2  tls {
    289  1.1.1.1.10.2  tls 	if (a != 0x12345678)
    290  1.1.1.1.10.2  tls 		return EFI_LOAD_ERROR;
    291  1.1.1.1.10.2  tls 	if (b != 0x23456789)
    292  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
    293  1.1.1.1.10.2  tls 	if (c != 0x3456789a)
    294  1.1.1.1.10.2  tls 		return EFI_UNSUPPORTED;
    295  1.1.1.1.10.2  tls 	if (d != 0x456789ab)
    296  1.1.1.1.10.2  tls 		return EFI_BAD_BUFFER_SIZE;
    297  1.1.1.1.10.2  tls 	if (e != 0x56789abc)
    298  1.1.1.1.10.2  tls 		return EFI_BUFFER_TOO_SMALL;
    299  1.1.1.1.10.2  tls 	if (f != 0x6789abcd)
    300  1.1.1.1.10.2  tls 		return EFI_NOT_READY;
    301  1.1.1.1.10.2  tls 	if (g != 0x789abcde)
    302  1.1.1.1.10.2  tls 		return EFI_DEVICE_ERROR;
    303  1.1.1.1.10.2  tls 	if (h != 0x89abcdef)
    304  1.1.1.1.10.2  tls 		return EFI_WRITE_PROTECTED;
    305  1.1.1.1.10.2  tls 	if (i != 0x9abcdef0)
    306  1.1.1.1.10.2  tls 		return EFI_OUT_OF_RESOURCES;
    307  1.1.1.1.10.2  tls 	if (j != 0xabcdef01)
    308  1.1.1.1.10.2  tls 		return EFI_VOLUME_CORRUPTED;
    309  1.1.1.1.10.2  tls 
    310  1.1.1.1.10.2  tls 	return EFI_SUCCESS;
    311  1.1.1.1.10.2  tls }
    312  1.1.1.1.10.2  tls 
    313  1.1.1.1.10.2  tls EFI_STATUS test_call10(void)
    314  1.1.1.1.10.2  tls {
    315  1.1.1.1.10.2  tls 	return uefi_call_wrapper(test_call10_callback, 10,
    316  1.1.1.1.10.2  tls 		0x12345678,
    317  1.1.1.1.10.2  tls 		0x23456789,
    318  1.1.1.1.10.2  tls 		0x3456789a,
    319  1.1.1.1.10.2  tls 		0x456789ab,
    320  1.1.1.1.10.2  tls 		0x56789abc,
    321  1.1.1.1.10.2  tls 		0x6789abcd,
    322  1.1.1.1.10.2  tls 		0x789abcde,
    323  1.1.1.1.10.2  tls 		0x89abcdef,
    324  1.1.1.1.10.2  tls 		0x9abcdef0,
    325  1.1.1.1.10.2  tls 		0xabcdef01);
    326  1.1.1.1.10.2  tls }
    327  1.1.1.1.10.2  tls 
    328  1.1.1.1.10.2  tls EFI_STATUS
    329  1.1.1.1.10.2  tls efi_main (EFI_HANDLE *image, EFI_SYSTEM_TABLE *systab)
    330  1.1.1.1.10.2  tls {
    331  1.1.1.1.10.2  tls 	EFI_STATUS rc = EFI_SUCCESS;
    332  1.1.1.1.10.2  tls 
    333  1.1.1.1.10.2  tls 	InitializeLib(image, systab);
    334  1.1.1.1.10.2  tls 	PoolAllocationType = 2; /* klooj */
    335  1.1.1.1.10.2  tls 
    336  1.1.1.1.10.2  tls #ifndef __x86_64__
    337  1.1.1.1.10.2  tls 	uefi_call_wrapper(systab->ConOut->OutputString, 2, systab->ConOut,
    338  1.1.1.1.10.2  tls 		L"This test is only valid on x86_64\n");
    339  1.1.1.1.10.2  tls 	return EFI_UNSUPPORTED;
    340  1.1.1.1.10.2  tls #endif
    341  1.1.1.1.10.2  tls 
    342  1.1.1.1.10.2  tls 	__asm__ volatile("out %0,%1" : : "a" ((uint8_t)0x14), "dN" (0x80));
    343  1.1.1.1.10.2  tls 
    344  1.1.1.1.10.2  tls 	Print(L"Hello\r\n");
    345  1.1.1.1.10.2  tls 	rc = test_failure();
    346  1.1.1.1.10.2  tls 	if (EFI_ERROR(rc)) {
    347  1.1.1.1.10.2  tls 		Print(L"Returning Failure works\n");
    348  1.1.1.1.10.2  tls 	} else {
    349  1.1.1.1.10.2  tls 		Print(L"Returning failure doesn't work.\r\n");
    350  1.1.1.1.10.2  tls 		Print(L"%%rax was 0x%016x, should have been 0x%016x\n",
    351  1.1.1.1.10.2  tls 			rc, EFI_UNSUPPORTED);
    352  1.1.1.1.10.2  tls 		return EFI_INVALID_PARAMETER;
    353  1.1.1.1.10.2  tls 	}
    354  1.1.1.1.10.2  tls 
    355  1.1.1.1.10.2  tls 	rc = test_call0();
    356  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    357  1.1.1.1.10.2  tls 		Print(L"0 args works just fine here.\r\n");
    358  1.1.1.1.10.2  tls 	} else {
    359  1.1.1.1.10.2  tls 		Print(L"0 args failed: 0x%016x\n", rc);
    360  1.1.1.1.10.2  tls 		return rc;
    361  1.1.1.1.10.2  tls 	}
    362  1.1.1.1.10.2  tls 
    363  1.1.1.1.10.2  tls 	rc = test_call1();
    364  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    365  1.1.1.1.10.2  tls 		Print(L"1 arg works just fine here.\r\n");
    366  1.1.1.1.10.2  tls 	} else {
    367  1.1.1.1.10.2  tls 		Print(L"1 arg failed: 0x%016x\n", rc);
    368  1.1.1.1.10.2  tls 		return rc;
    369  1.1.1.1.10.2  tls 	}
    370  1.1.1.1.10.2  tls 
    371  1.1.1.1.10.2  tls 	rc = test_call2();
    372  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    373  1.1.1.1.10.2  tls 		Print(L"2 args works just fine here.\r\n");
    374  1.1.1.1.10.2  tls 	} else {
    375  1.1.1.1.10.2  tls 		Print(L"2 args failed: 0x%016x\n", rc);
    376  1.1.1.1.10.2  tls 		return rc;
    377  1.1.1.1.10.2  tls 	}
    378  1.1.1.1.10.2  tls 
    379  1.1.1.1.10.2  tls 	rc = test_call3();
    380  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    381  1.1.1.1.10.2  tls 		Print(L"3 args works just fine here.\r\n");
    382  1.1.1.1.10.2  tls 	} else {
    383  1.1.1.1.10.2  tls 		Print(L"3 args failed: 0x%016x\n", rc);
    384  1.1.1.1.10.2  tls 		return rc;
    385  1.1.1.1.10.2  tls 	}
    386  1.1.1.1.10.2  tls 
    387  1.1.1.1.10.2  tls 	rc = test_call4();
    388  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    389  1.1.1.1.10.2  tls 		Print(L"4 args works just fine here.\r\n");
    390  1.1.1.1.10.2  tls 	} else {
    391  1.1.1.1.10.2  tls 		Print(L"4 args failed: 0x%016x\n", rc);
    392  1.1.1.1.10.2  tls 		return rc;
    393  1.1.1.1.10.2  tls 	}
    394  1.1.1.1.10.2  tls 
    395  1.1.1.1.10.2  tls 	rc = test_call5();
    396  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    397  1.1.1.1.10.2  tls 		Print(L"5 args works just fine here.\r\n");
    398  1.1.1.1.10.2  tls 	} else {
    399  1.1.1.1.10.2  tls 		Print(L"5 args failed: 0x%016x\n", rc);
    400  1.1.1.1.10.2  tls 		return rc;
    401  1.1.1.1.10.2  tls 	}
    402  1.1.1.1.10.2  tls 
    403  1.1.1.1.10.2  tls 	rc = test_call6();
    404  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    405  1.1.1.1.10.2  tls 		Print(L"6 args works just fine here.\r\n");
    406  1.1.1.1.10.2  tls 	} else {
    407  1.1.1.1.10.2  tls 		Print(L"6 args failed: 0x%016x\n", rc);
    408  1.1.1.1.10.2  tls 		return rc;
    409  1.1.1.1.10.2  tls 	}
    410  1.1.1.1.10.2  tls 
    411  1.1.1.1.10.2  tls 	rc = test_call7();
    412  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    413  1.1.1.1.10.2  tls 		Print(L"7 args works just fine here.\r\n");
    414  1.1.1.1.10.2  tls 	} else {
    415  1.1.1.1.10.2  tls 		Print(L"7 args failed: 0x%016x\n", rc);
    416  1.1.1.1.10.2  tls 		return rc;
    417  1.1.1.1.10.2  tls 	}
    418  1.1.1.1.10.2  tls 
    419  1.1.1.1.10.2  tls 	rc = test_call8();
    420  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    421  1.1.1.1.10.2  tls 		Print(L"8 args works just fine here.\r\n");
    422  1.1.1.1.10.2  tls 	} else {
    423  1.1.1.1.10.2  tls 		Print(L"8 args failed: 0x%016x\n", rc);
    424  1.1.1.1.10.2  tls 		return rc;
    425  1.1.1.1.10.2  tls 	}
    426  1.1.1.1.10.2  tls 
    427  1.1.1.1.10.2  tls 	rc = test_call9();
    428  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    429  1.1.1.1.10.2  tls 		Print(L"9 args works just fine here.\r\n");
    430  1.1.1.1.10.2  tls 	} else {
    431  1.1.1.1.10.2  tls 		Print(L"9 args failed: 0x%016x\n", rc);
    432  1.1.1.1.10.2  tls 		return rc;
    433  1.1.1.1.10.2  tls 	}
    434  1.1.1.1.10.2  tls 
    435  1.1.1.1.10.2  tls 	rc = test_call10();
    436  1.1.1.1.10.2  tls 	if (!EFI_ERROR(rc)) {
    437  1.1.1.1.10.2  tls 		Print(L"10 args works just fine here.\r\n");
    438  1.1.1.1.10.2  tls 	} else {
    439  1.1.1.1.10.2  tls 		Print(L"10 args failed: 0x%016x\n", rc);
    440  1.1.1.1.10.2  tls 		return rc;
    441  1.1.1.1.10.2  tls 	}
    442  1.1.1.1.10.2  tls 
    443  1.1.1.1.10.2  tls 	return rc;
    444  1.1.1.1.10.2  tls }
    445