/* * void bzero64(uint64_t dst, uint64_t len) * * Layout on stack: * len 24,28 * dst 16,20 * retaddr 12 * %ebx 8 * %esi 4 * %edi 0 */ .globl bzero64 .type bzero64,@function .size bzero64,ebzero64-bzero64 /* arrive here in 32 bit mode */ bzero64: pushl %ebx pushl %esi pushl %edi call base base: popl %esi /* relocatable address of "base" */ /* Set up for inter-segment jump to 64 bit code mode */ movl %esi,%edx addl $to64-base,%edx pushl $43 /* $GSEL(GUCODE_SEL, SEL_UPL) */ pushl %edx lretl .code64 .p2align 4 to64: movq %rsi,%r9 /* Set up our escape to 32 bit */ addq $to32-base,%r9 movq 16(%rsp),%rdi /* dst */ movq 24(%rsp),%rsi /* len */ cld /* set fill direction forward */ xorq %rax,%rax /* Fill data */ cmpq $16,%rsi /* too short? (just do byte fill) */ jb 1f movq %rdi,%rcx /* misalignment */ negq %rcx andq $7,%rcx subq %rcx,%rsi rep /* zero till aligned */ stosb movq %rsi,%rcx /* zero rest of words */ shrq $3,%rcx andq $7,%rsi rep stosq 1: movq %rsi,%rcx /* zero remainder by bytes */ rep stosb /* Jump back to 32 bit code segment */ pushq $27 /* GSEL(GUCODE32_UPL, SEL_UPL) */ pushq %r9 lretq .code32 .p2align 4 to32: popl %edi popl %esi popl %ebx ret ebzero64: