Fork me on GitHub

root/include/fiwix/asm.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * fiwix/include/fiwix/asm.h
   3  *
   4  * Copyright 2018-2021, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #ifndef _FIWIX_ASM_H
   9 #define _FIWIX_ASM_H
  10 
  11 extern void except0(void);
  12 extern void except1(void);
  13 extern void except2(void);
  14 extern void except3(void);
  15 extern void except4(void);
  16 extern void except5(void);
  17 extern void except6(void);
  18 extern void except7(void);
  19 extern void except8(void);
  20 extern void except9(void);
  21 extern void except10(void);
  22 extern void except11(void);
  23 extern void except12(void);
  24 extern void except13(void);
  25 extern void except14(void);
  26 extern void except15(void);
  27 extern void except16(void);
  28 extern void except17(void);
  29 extern void except18(void);
  30 extern void except19(void);
  31 extern void except20(void);
  32 extern void except21(void);
  33 extern void except22(void);
  34 extern void except23(void);
  35 extern void except24(void);
  36 extern void except25(void);
  37 extern void except26(void);
  38 extern void except27(void);
  39 extern void except28(void);
  40 extern void except29(void);
  41 extern void except30(void);
  42 extern void except31(void);
  43 
  44 extern void irq0(void);
  45 extern void irq1(void);
  46 extern void irq2(void);
  47 extern void irq3(void);
  48 extern void irq4(void);
  49 extern void irq5(void);
  50 extern void irq6(void);
  51 extern void irq7(void);
  52 extern void irq8(void);
  53 extern void irq9(void);
  54 extern void irq10(void);
  55 extern void irq11(void);
  56 extern void irq12(void);
  57 extern void irq13(void);
  58 extern void irq14(void);
  59 extern void irq15(void);
  60 extern void unknown_irq(void);
  61 
  62 extern void switch_to_user_mode(void);
  63 extern void sighandler_trampoline(void);
  64 extern void end_sighandler_trampoline(void);
  65 extern void syscall(void);
  66 extern void return_from_syscall(void);
  67 extern void do_switch(unsigned int *, unsigned int *, unsigned int, unsigned int, unsigned int, unsigned short int);
  68 
  69 int cpuid(void);
  70 int getfpu(void);
  71 int vendor_id(void);
  72 int signature_flags(void);
  73 int brand_str(void);
  74 int tlbinfo(void);
  75 
  76 unsigned char inport_b(unsigned int);
  77 short int inport_w(unsigned int);
  78 void inport_sw(unsigned int, void *, unsigned int);
  79 void outport_b(unsigned int, unsigned char);
  80 void outport_w(unsigned int, unsigned int);
  81 void outport_sw(unsigned int, void *, unsigned int);
  82 
  83 void load_gdt(unsigned int);
  84 void load_idt(unsigned int);
  85 void activate_kpage_dir(void);
  86 void load_tr(unsigned int);
  87 unsigned long long int get_rdtsc(void);
  88 void invalidate_tlb(void);
  89 
  90 #define CLI() __asm__ __volatile__ ("cli":::"memory")
  91 #define STI() __asm__ __volatile__ ("sti":::"memory")
  92 #define NOP() __asm__ __volatile__ ("nop":::"memory")
  93 #define HLT() __asm__ __volatile__ ("hlt":::"memory")
  94 
  95 #define GET_CR2(cr2) __asm__ __volatile__ ("movl %%cr2, %0" : "=r" (cr2));
  96 #define GET_ESP(esp) __asm__ __volatile__ ("movl %%esp, %0" : "=r" (esp));
  97 #define SET_ESP(esp) __asm__ __volatile__ ("movl %0, %%esp" :: "r" (esp));
  98 
  99 #define SAVE_FLAGS(flags)                       \
 100         __asm__ __volatile__(                   \
 101                 "pushfl ; popl %0\n\t"          \
 102                 : "=r" (flags)                  \
 103                 : /* no input */                \
 104                 : "memory"                      \
 105         );
 106 
 107 #define RESTORE_FLAGS(x)                        \
 108         __asm__ __volatile__(                   \
 109                 "pushl %0 ; popfl\n\t"          \
 110                 : /* no output */               \
 111                 : "r" (flags)                   \
 112                 : "memory"                      \
 113         );
 114 
 115 #define USER_SYSCALL(num, arg1, arg2, arg3)     \
 116         __asm__ __volatile__(                   \
 117                 "movl   %0, %%eax\n\t"          \
 118                 "movl   %1, %%ebx\n\t"          \
 119                 "movl   %2, %%ecx\n\t"          \
 120                 "movl   %3, %%edx\n\t"          \
 121                 "int    $0x80\n\t"              \
 122                 : /* no output */               \
 123                 : "eax"((unsigned int)num), "ebx"((unsigned int)arg1), "ecx"((unsigned int)arg2), "edx"((unsigned int)arg3)     \
 124         );
 125 
 126 /*
 127 static inline unsigned long long int get_rdtsc(void)
 128 {
 129         unsigned int eax, edx;
 130 
 131         __asm__ __volatile__("rdtsc" : "=a" (eax), "=d" (edx));
 132         return ((unsigned long long int)eax) | (((unsigned long long int)edx) << 32);
 133 }
 134 */
 135 
 136 #endif /* _FIWIX_ASM_H */

/* [previous][next][first][last][top][bottom][index][help] */