.include "../include/machine10-main.inc" .macro CALL method, id, target, target_len, body_reg, body_len_reg, expected movl $\method, M10_ABI_V3_METHOD(%r13) movq $\id, M10_ABI_V3_REQUEST_ID(%r13) leaq \target(%rip), %rax movq %rax, M10_ABI_V3_TARGET_ADDRESS(%r13) movq $\target_len, M10_ABI_V3_TARGET_LENGTH(%r13) movq \body_reg, M10_ABI_V3_BODY_ADDRESS(%r13) movq \body_len_reg, M10_ABI_V3_BODY_LENGTH(%r13) movq $0, M10_ABI_V3_RESPONSE_LENGTH(%r13) movl $0, M10_ABI_V3_HTTP_STATUS(%r13) movl $0, M10_ABI_V3_ERROR(%r13) movw $M10_DOORBELL_PORT, %dx movl $M10_OP_HTTP_CALL, %eax outl %eax, %dx cmpl $M10_ERROR_NONE, M10_ABI_V3_ERROR(%r13) jne failed cmpl $\expected, M10_ABI_V3_HTTP_STATUS(%r13) je 9f .if \expected == 201 cmpl $200, M10_ABI_V3_HTTP_STATUS(%r13) jne failed .else jne failed .endif 9: .endm .section .text .code64 .global _start _start: movq %rdi, %r14 movq %r8, %r13 movabsq $M10_ABI_MAGIC, %rax movq %rax, M10_ABI_MAGIC_OFFSET(%r13) movl $M10_ABI_VERSION_MAINBOARD, M10_ABI_VERSION_OFFSET(%r13) movq %rdx, M10_ABI_V3_RESPONSE_ADDRESS(%r13) movq %rcx, M10_ABI_V3_RESPONSE_CAPACITY(%r13) movq $0, M10_ABI_V3_RESPONSE_LENGTH(%r13) movl $200, M10_ABI_V3_HTTP_STATUS(%r13) movl $M10_ERROR_NONE, M10_ABI_V3_ERROR(%r13) movq $0, M10_ABI_V3_COMPLETION_SEQUENCE(%r13) movl M10_EVENT_TYPE_OFFSET(%r14), %eax movl %eax, M10_ABI_V3_EVENT_TYPE(%r13) movq M10_EVENT_OCCURRENCE_OFFSET(%r14), %rax movq %rax, M10_ABI_V3_EVENT_OCCURRENCE(%r13) movl $M10_TIMER_KEEP, M10_ABI_V3_TIMER_ACTION(%r13) movq $0, M10_ABI_V3_WAKE_AFTER_MS(%r13) movl $M10_DISPOSITION_SLEEP, M10_ABI_V3_DISPOSITION(%r13) movabsq $M10_RETAINED_COUNTER_ADDRESS, %r10 movq M10_EVENT_GENERATION_OFFSET(%r14), %rax cmpq %rax, (%r10) jne failed incq (%r10) cmpl $M10_EVENT_INIT, M10_EVENT_TYPE_OFFSET(%r14) je commit movq M10_EVENT_PAYLOAD_ADDRESS(%r14), %r9 movq M10_EVENT_PAYLOAD_LENGTH(%r14), %r11 CALL M10_METHOD_PUT, 1, value_target, (value_target_end-value_target), %r9, %r11, 201 xorq %r9, %r9 xorq %r11, %r11 CALL M10_METHOD_GET, 2, value_target, (value_target_end-value_target), %r9, %r11, 200 commit: movl $M10_OP_COMMIT_SLEEP, %eax jmp ring failed: movl $M10_ERROR_BAD_EVENT, M10_ABI_V3_ERROR(%r13) movl $M10_OP_EXIT, %eax ring: movw $M10_DOORBELL_PORT, %dx outl %eax, %dx cli hlt .section .rodata value_target: .ascii "/api/p10/machine-starter/latest" value_target_end: