1ae115bc7Smrj/* 2ae115bc7Smrj * CDDL HEADER START 3ae115bc7Smrj * 4ae115bc7Smrj * The contents of this file are subject to the terms of the 5ae115bc7Smrj * Common Development and Distribution License (the "License"). 6ae115bc7Smrj * You may not use this file except in compliance with the License. 7ae115bc7Smrj * 8ae115bc7Smrj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9ae115bc7Smrj * or http://www.opensolaris.org/os/licensing. 10ae115bc7Smrj * See the License for the specific language governing permissions 11ae115bc7Smrj * and limitations under the License. 12ae115bc7Smrj * 13ae115bc7Smrj * When distributing Covered Code, include this CDDL HEADER in each 14ae115bc7Smrj * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15ae115bc7Smrj * If applicable, add the following below this CDDL HEADER, with the 16ae115bc7Smrj * fields enclosed by brackets "[]" replaced with your own identifying 17ae115bc7Smrj * information: Portions Copyright [yyyy] [name of copyright owner] 18ae115bc7Smrj * 19ae115bc7Smrj * CDDL HEADER END 20ae115bc7Smrj */ 21ae115bc7Smrj 22ae115bc7Smrj/* 23*26a04d67SDave Plauger * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24ae115bc7Smrj * Use is subject to license terms. 25ae115bc7Smrj */ 26ae115bc7Smrj 27ae115bc7Smrj/ 28ae115bc7Smrj/ Inline functions specific to the i86pc kernel running on bare metal. 29ae115bc7Smrj/ 30ae115bc7Smrj 31ae115bc7Smrj/ 32ae115bc7Smrj/ return value of cr3 register 33ae115bc7Smrj/ 34ae115bc7Smrj .inline getcr3,0 35ae115bc7Smrj movl %cr3, %eax 36ae115bc7Smrj .end 37ae115bc7Smrj 38ae115bc7Smrj/ 39ae115bc7Smrj/ reload cr3 register with its current value 40ae115bc7Smrj/ 41ae115bc7Smrj .inline reload_cr3,0 42ae115bc7Smrj movl %cr3, %eax 43ae115bc7Smrj movl %eax, %cr3 44ae115bc7Smrj .end 45ae115bc7Smrj 46ae115bc7Smrj/* 47ae115bc7Smrj * Put a new value into cr3 (page table base register 48ae115bc7Smrj * void setcr3(void *value) 49ae115bc7Smrj */ 50ae115bc7Smrj .inline setcr3,4 51ae115bc7Smrj movl (%esp), %eax 52ae115bc7Smrj movl %eax, %cr3 53ae115bc7Smrj .end 54ae115bc7Smrj 55ae115bc7Smrj/ 56ae115bc7Smrj/ enable interrupts 57ae115bc7Smrj/ 58ae115bc7Smrj .inline sti,0 59ae115bc7Smrj sti 60ae115bc7Smrj .end 61ae115bc7Smrj 62ae115bc7Smrj/ 63ae115bc7Smrj/ disable interrupts 64ae115bc7Smrj/ 65ae115bc7Smrj .inline cli,0 66ae115bc7Smrj cli 67ae115bc7Smrj .end 68ae115bc7Smrj 69ae115bc7Smrj/ 70ae115bc7Smrj/ disable interrupts and return value describing if interrupts were enabled 71ae115bc7Smrj/ 72ae115bc7Smrj .inline clear_int_flag,0 73ae115bc7Smrj pushfl 74ae115bc7Smrj cli 75ae115bc7Smrj popl %eax 76ae115bc7Smrj .end 77ae115bc7Smrj 78ae115bc7Smrj .inline intr_clear,0 79ae115bc7Smrj pushfl 80ae115bc7Smrj cli 81ae115bc7Smrj popl %eax 82ae115bc7Smrj .end 83ae115bc7Smrj 84ae115bc7Smrj/ 85ae115bc7Smrj/ return the flags register 86ae115bc7Smrj/ 87ae115bc7Smrj .inline getflags,0 88ae115bc7Smrj pushfl 89ae115bc7Smrj popl %eax 90ae115bc7Smrj .end 91ae115bc7Smrj 92ae115bc7Smrj/ 93ae115bc7Smrj/ restore interrupt enable flag to value returned from 'clear_int_flag' above 94ae115bc7Smrj/ 95ae115bc7Smrj .inline restore_int_flag,4 96a563a037Sbholler testl $0x200, (%esp) 97a563a037Sbholler jz 1f 98a563a037Sbholler sti 99a563a037Sbholler1: 100ae115bc7Smrj .end 101ae115bc7Smrj 102ae115bc7Smrj .inline intr_restore,4 103a563a037Sbholler testl $0x200, (%esp) 104a563a037Sbholler jz 1f 105a563a037Sbholler sti 106a563a037Sbholler1: 107ae115bc7Smrj .end 108ae115bc7Smrj 109ae115bc7Smrj/ 110ae115bc7Smrj/ in and out 111ae115bc7Smrj/ 112ae115bc7Smrj .inline inb,4 113ae115bc7Smrj movl (%esp), %edx 114ae115bc7Smrj xorl %eax, %eax 115ae115bc7Smrj inb (%dx) 116ae115bc7Smrj .end 117ae115bc7Smrj 118ae115bc7Smrj .inline inw,4 119ae115bc7Smrj movl (%esp), %edx 120ae115bc7Smrj xorl %eax, %eax 121ae115bc7Smrj inw (%dx) 122ae115bc7Smrj .end 123ae115bc7Smrj 124ae115bc7Smrj .inline inl,4 125ae115bc7Smrj movl (%esp), %edx 126ae115bc7Smrj xorl %eax, %eax 127ae115bc7Smrj inl (%dx) 128ae115bc7Smrj .end 129ae115bc7Smrj 130ae115bc7Smrj .inline outb,8 131ae115bc7Smrj movl (%esp), %edx 132ae115bc7Smrj movl 4(%esp), %eax 133ae115bc7Smrj outb (%dx) 134ae115bc7Smrj .end 135ae115bc7Smrj 136ae115bc7Smrj .inline outw,8 137ae115bc7Smrj movl (%esp), %edx 138ae115bc7Smrj movl 4(%esp), %eax 139ae115bc7Smrj outw (%dx) 140ae115bc7Smrj .end 141ae115bc7Smrj 142ae115bc7Smrj .inline outl,8 143ae115bc7Smrj movl (%esp), %edx 144ae115bc7Smrj movl 4(%esp), %eax 145ae115bc7Smrj outl (%dx) 146ae115bc7Smrj .end 147ae115bc7Smrj 148ae115bc7Smrj/* 149ae115bc7Smrj * Invalidate TLB translation to 1 page. 150ae115bc7Smrj * void mmu_tlbflush_entry(void *addr) 151ae115bc7Smrj */ 152ae115bc7Smrj .inline mmu_tlbflush_entry,4 153ae115bc7Smrj movl (%esp), %eax 154ae115bc7Smrj invlpg (%eax) 155ae115bc7Smrj .end 156ae115bc7Smrj 157ae115bc7Smrj/* 158ae115bc7Smrj * Call the halt instruction. This will put the CPU to sleep until 159ae115bc7Smrj * it is again awoken via an interrupt. 160ae115bc7Smrj * This function should be called with interrupts already disabled 161ae115bc7Smrj * for the CPU. 162ae115bc7Smrj * Note that "sti" will only enable interrupts at the end of the 163ae115bc7Smrj * subsequent instruction...in this case: "hlt". 164ae115bc7Smrj */ 165ae115bc7Smrj .inline i86_halt,0 166ae115bc7Smrj sti 167ae115bc7Smrj hlt 168ae115bc7Smrj .end 169ae115bc7Smrj 170ae115bc7Smrj/* 171ae115bc7Smrj * execute the bsrw instruction 172ae115bc7Smrj * int bsrw_insn(uint16_t) 173ae115bc7Smrj */ 174ae115bc7Smrj .inline bsrw_insn,4 175ae115bc7Smrj xorl %eax, %eax 176ae115bc7Smrj movw (%esp), %cx 177ae115bc7Smrj bsrw %cx, %ax 178ae115bc7Smrj .end 179