13446Smrj/* 23446Smrj * CDDL HEADER START 33446Smrj * 43446Smrj * The contents of this file are subject to the terms of the 53446Smrj * Common Development and Distribution License (the "License"). 63446Smrj * You may not use this file except in compliance with the License. 73446Smrj * 83446Smrj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93446Smrj * or http://www.opensolaris.org/os/licensing. 103446Smrj * See the License for the specific language governing permissions 113446Smrj * and limitations under the License. 123446Smrj * 133446Smrj * When distributing Covered Code, include this CDDL HEADER in each 143446Smrj * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153446Smrj * If applicable, add the following below this CDDL HEADER, with the 163446Smrj * fields enclosed by brackets "[]" replaced with your own identifying 173446Smrj * information: Portions Copyright [yyyy] [name of copyright owner] 183446Smrj * 193446Smrj * CDDL HEADER END 203446Smrj */ 213446Smrj 223446Smrj/* 23*9171Sxiuyan.wang@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 243446Smrj * Use is subject to license terms. 253446Smrj */ 263446Smrj 273446Smrj 283446Smrj/ 293446Smrj/ Inline functions specific to the i86pc kernel running on bare metal. 303446Smrj/ 313446Smrj 323446Smrj/ 333446Smrj/ return value of cr3 register 343446Smrj/ 353446Smrj .inline getcr3,0 363446Smrj movq %cr3, %rax 373446Smrj .end 383446Smrj 393446Smrj/ 403446Smrj/ reload cr3 register with its current value 413446Smrj/ 423446Smrj .inline reload_cr3,0 433446Smrj movq %cr3, %rdi 443446Smrj movq %rdi, %cr3 453446Smrj .end 463446Smrj 473446Smrj/ 487656SSherry.Moore@Sun.COM/ set cr3 register with new value 497656SSherry.Moore@Sun.COM/ 507656SSherry.Moore@Sun.COM .inline setcr3,0 517656SSherry.Moore@Sun.COM movq %rdi, %cr3 527656SSherry.Moore@Sun.COM .end 537656SSherry.Moore@Sun.COM 547656SSherry.Moore@Sun.COM/ 553446Smrj/ return value of cr8 register 563446Smrj/ 573446Smrj .inline getcr8,0 583446Smrj movq %cr8, %rax 593446Smrj .end 603446Smrj 613446Smrj/ 623446Smrj/ set cr8 register 633446Smrj/ 643446Smrj .inline setcr8,0 653446Smrj movq %rdi, %cr8 663446Smrj .end 673446Smrj 683446Smrj/ 693446Smrj/ enable interrupts 703446Smrj/ 713446Smrj .inline sti,0 723446Smrj sti 733446Smrj .end 743446Smrj 753446Smrj/ 763446Smrj/ disable interrupts 773446Smrj/ 783446Smrj .inline cli,0 793446Smrj cli 803446Smrj .end 813446Smrj 823446Smrj/ 833446Smrj/ disable interrupts and return value describing if interrupts were enabled 843446Smrj/ 853446Smrj .inline clear_int_flag,0 863446Smrj pushfq 873446Smrj cli 883446Smrj popq %rax 893446Smrj .end 903446Smrj 913446Smrj .inline intr_clear,0 923446Smrj pushfq 933446Smrj cli 943446Smrj popq %rax 953446Smrj .end 963446Smrj 973446Smrj/ 983446Smrj/ return the value of the flags register 993446Smrj/ 1003446Smrj .inline getflags,0 1013446Smrj pushfq 1023446Smrj popq %rax 1033446Smrj .end 1043446Smrj 1053446Smrj/ 1063446Smrj/ restore interrupt enable flag to value returned from 'clear_int_flag' above 1073446Smrj/ 1083446Smrj .inline restore_int_flag,4 1096336Sbholler testq $0x200, %rdi 1106336Sbholler jz 1f 1116336Sbholler sti 1126336Sbholler1: 1133446Smrj .end 1143446Smrj 1153446Smrj .inline intr_restore,4 1166336Sbholler testq $0x200, %rdi 1176336Sbholler jz 1f 1186336Sbholler sti 1196336Sbholler1: 1203446Smrj .end 1213446Smrj 1223446Smrj/ 1233446Smrj/ in and out 1243446Smrj/ 1253446Smrj .inline inb,4 1263446Smrj movq %rdi, %rdx 1273446Smrj xorq %rax, %rax 1283446Smrj inb (%dx) 1293446Smrj .end 1303446Smrj 1313446Smrj .inline inw,4 1323446Smrj movq %rdi, %rdx 1333446Smrj xorq %rax, %rax 1343446Smrj inw (%dx) 1353446Smrj .end 1363446Smrj 1373446Smrj .inline inl,4 1383446Smrj movq %rdi, %rdx 1393446Smrj xorq %rax, %rax 1403446Smrj inl (%dx) 1413446Smrj .end 1423446Smrj 1433446Smrj .inline outb,8 1443446Smrj movq %rdi, %rdx 1453446Smrj movq %rsi, %rax 1463446Smrj outb (%dx) 1473446Smrj .end 1483446Smrj 1493446Smrj .inline outw,8 1503446Smrj movq %rdi, %rdx 1513446Smrj movq %rsi, %rax 1523446Smrj outw (%dx) 1533446Smrj .end 1543446Smrj 1553446Smrj .inline outl,8 1563446Smrj movq %rdi, %rdx 1573446Smrj movq %rsi, %rax 1583446Smrj outl (%dx) 1593446Smrj .end 1603446Smrj 1613446Smrj/* 1623446Smrj * Call the halt instruction. This will put the CPU to sleep until 1633446Smrj * it is again awoken via an interrupt. 1643446Smrj * This function should be called with interrupts already disabled 1653446Smrj * for the CPU. 1663446Smrj * Note that "sti" will only enable interrupts at the end of the 1673446Smrj * subsequent instruction...in this case: "hlt". 1683446Smrj */ 1693446Smrj .inline i86_halt,0 1703446Smrj sti 1713446Smrj hlt 1723446Smrj .end 1733446Smrj/ 1743446Smrj/ execute the bsrw instruction 1753446Smrj/ 1763446Smrj .inline bsrw_insn,4 1773446Smrj xorl %eax, %eax 1783446Smrj bsrw %di, %ax 1793446Smrj .end 180