1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#include <sys/asm_linkage.h> 28#include <sys/asm_misc.h> 29 30#if defined(__lint) 31 32#include "dboot_asm.h" 33 34/* ARGSUSED */ 35uint32_t 36get_cpuid_edx(uint32_t *eax) 37{ return (0); } 38 39/* ARGSUSED */ 40void 41outb(int port, uint8_t value) 42{} 43 44/* ARGSUSED */ 45uint8_t 46inb(int port) 47{ return (0); } 48 49#else /* __lint */ 50 51#if defined(__amd64) 52 53 /* 54 * do a cpuid instruction, returning the eax/edx values 55 * 56 * uint32_t get_cpuid_edx(uint32_t *eax) 57 */ 58 ENTRY_NP(get_cpuid_edx) 59 pushq %rbx 60 movl (%rdi), %eax 61 cpuid 62 movl %eax, (%rdi) 63 movl %edx, %eax 64 popq %rbx 65 ret 66 SET_SIZE(get_cpuid_edx) 67 68 /* 69 * void outb(int port, uint8_t value) 70 */ 71 ENTRY(outb) 72 movw %di, %dx 73 movb %sil, %al 74 outb (%dx) 75 ret 76 SET_SIZE(outb) 77 78 /* 79 * uint8_t inb(int port) 80 */ 81 ENTRY(inb) 82 xorl %eax, %eax 83 movw %di, %dx 84 inb (%dx) 85 ret 86 SET_SIZE(inb) 87 88 ENTRY(htonl) 89 movl %edi, %eax 90 bswap %eax 91 ret 92 SET_SIZE(htonl) 93 94#elif defined(__i386) 95 96 .code32 97 98 /* 99 * do a cpuid instruction, returning the eax/edx values 100 * 101 * uint32_t get_cpuid_edx(uint32_t *eax) 102 */ 103 ENTRY_NP(get_cpuid_edx) 104 movl 4(%esp), %ecx 105 movl (%ecx), %eax 106 pushl %ebx 107 cpuid 108 popl %ebx 109 movl 4(%esp), %ecx 110 movl %eax, (%ecx) 111 movl %edx, %eax 112 ret 113 SET_SIZE(get_cpuid_edx) 114 115 /* 116 * void outb(int port, uint8_t value) 117 */ 118 ENTRY_NP(outb) 119 movl 4(%esp), %edx 120 movl 8(%esp), %eax 121 outb (%dx) 122 ret 123 SET_SIZE(outb) 124 125 /* 126 * uint8_t inb(int port) 127 */ 128 ENTRY_NP(inb) 129 movl 4(%esp), %edx 130 inb (%dx) 131 andl $0xff, %eax 132 ret 133 SET_SIZE(inb) 134 135 ENTRY(htonl) 136 movl 4(%esp), %eax 137 bswap %eax 138 ret 139 SET_SIZE(htonl) 140 141#endif /* __i386 */ 142 143#endif /* __lint */ 144