UbixOS  2.0
cpu.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _CPU_H_
30 #define _CPU_H_
31 
32 #include <sys/types.h>
33 
34 /*
35  * 386 processor status longword.
36  */
37 #define PSL_C 0x00000001 /* carry bit */
38 #define PSL_PF 0x00000004 /* parity bit */
39 #define PSL_AF 0x00000010 /* bcd carry bit */
40 #define PSL_Z 0x00000040 /* zero bit */
41 #define PSL_N 0x00000080 /* negative bit */
42 #define PSL_T 0x00000100 /* trace enable bit */
43 #define PSL_I 0x00000200 /* interrupt enable bit */
44 #define PSL_D 0x00000400 /* string instruction direction bit */
45 #define PSL_V 0x00000800 /* overflow bit */
46 #define PSL_IOPL 0x00003000 /* i/o privilege level */
47 #define PSL_NT 0x00004000 /* nested task bit */
48 #define PSL_RF 0x00010000 /* resume flag bit */
49 #define PSL_VM 0x00020000 /* virtual 8086 mode bit */
50 #define PSL_AC 0x00040000 /* alignment checking */
51 #define PSL_VIF 0x00080000 /* virtual interrupt enable */
52 #define PSL_VIP 0x00100000 /* virtual interrupt pending */
53 #define PSL_ID 0x00200000 /* identification bit */
54 
55 /* Read Contents Of CR0 */
56 static __inline u_int rcr0(void) {
57  u_int data;
58  __asm __volatile("movl %%cr0,%0" : "=r" (data));
59  return (data);
60 }
61 
62 /* Write To CR0 */
63 static __inline void load_cr0(u_int data) {
64  __asm __volatile("movl %0,%%cr0" : : "r" (data));
65 }
66 
67 static __inline u_int rcr2(void) {
68  u_int data;
69 
70  __asm __volatile("movl %%cr2,%0" : "=r" (data));
71  return (data);
72 }
73 
74 static __inline u_int rcr3(void) {
75  u_int data;
76 
77  __asm __volatile("movl %%cr3,%0" : "=r" (data));
78  return (data);
79 }
80 
81 static __inline void load_cr3(u_int data) {
82  __asm __volatile("movl %0,%%cr3" : : "r" (data) : "memory");
83 }
84 
85 static __inline u_int rcr4(void) {
86  u_int data;
87 
88  __asm __volatile("movl %%cr4,%0" : "=r" (data));
89  return (data);
90 }
91 
92 static __inline void load_cr4(u_int data) {
93  __asm __volatile("movl %0,%%cr4" : : "r" (data));
94 }
95 
96 static __inline void invlpg(u_int addr) {
97  __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory");
98 }
99 
100 #endif
101 
102 /***
103  END
104  ***/
__inline
#define __inline
Definition: cdefs.h:179
types.h
__asm
__asm(".globl sysFork_old \n" "sysFork_old: \n" " xor %eax,%eax \n" " call schedNewTask \n" " testl %eax,%eax \n" " je fork_ret \n" " pushl %esi \n" " pushl %edi \n" " pushl %ebp \n" " pushl %eax \n" " call fork_copyProcess \n" " movl %eax,(%ebx) \n" " addl $16,%esp \n" "fork_ret: \n" " ret \n")
u_int
unsigned int u_int
Definition: types.h:72
__volatile
#define __volatile
Definition: cdefs.h:181