Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /**
  2.  * This file has no copyright assigned and is placed in the Public Domain.
  3.  * This file is part of the w64 mingw-runtime package.
  4.  * No warranty is given; refer to the file DISCLAIMER within this package.
  5.  */
  6. #ifndef _INC_CONIO
  7. #define _INC_CONIO
  8.  
  9. #include <_mingw.h>
  10.  
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15.   _CRTIMP char *_cgets(char *_Buffer);
  16.   _CRTIMP int __cdecl _cprintf(const char *_Format,...);
  17.   _CRTIMP int __cdecl _cputs(const char *_Str);
  18.   _CRTIMP int __cdecl _cscanf(const char *_Format,...);
  19.   _CRTIMP int __cdecl _cscanf_l(const char *_Format,_locale_t _Locale,...);
  20.   _CRTIMP int __cdecl _getch(void);
  21.   _CRTIMP int __cdecl _getche(void);
  22.   _CRTIMP int __cdecl _vcprintf(const char *_Format,va_list _ArgList);
  23.   _CRTIMP int __cdecl _cprintf_p(const char *_Format,...);
  24.   _CRTIMP int __cdecl _vcprintf_p(const char *_Format,va_list _ArgList);
  25.   _CRTIMP int __cdecl _cprintf_l(const char *_Format,_locale_t _Locale,...);
  26.   _CRTIMP int __cdecl _vcprintf_l(const char *_Format,_locale_t _Locale,va_list _ArgList);
  27.   _CRTIMP int __cdecl _cprintf_p_l(const char *_Format,_locale_t _Locale,...);
  28.   _CRTIMP int __cdecl _vcprintf_p_l(const char *_Format,_locale_t _Locale,va_list _ArgList);
  29.   _CRTIMP int __cdecl _kbhit(void);
  30.  
  31. #if defined(_X86_) && !defined(__x86_64)
  32.   int __cdecl _inp(unsigned short);
  33.   unsigned short __cdecl _inpw(unsigned short);
  34.   unsigned long __cdecl _inpd(unsigned short);
  35.   int __cdecl _outp(unsigned short,int);
  36.   unsigned short __cdecl _outpw(unsigned short,unsigned short);
  37.   unsigned long __cdecl _outpd(unsigned short,unsigned long);
  38. #endif
  39.  
  40.   _CRTIMP int __cdecl _putch(int _Ch);
  41.   _CRTIMP int __cdecl _ungetch(int _Ch);
  42.   _CRTIMP int __cdecl _getch_nolock(void);
  43.   _CRTIMP int __cdecl _getche_nolock(void);
  44.   _CRTIMP int __cdecl _putch_nolock(int _Ch);
  45.   _CRTIMP int __cdecl _ungetch_nolock(int _Ch);
  46.  
  47. #ifndef _WCONIO_DEFINED
  48. #define _WCONIO_DEFINED
  49.  
  50. #ifndef WEOF
  51. #define WEOF (wint_t)(0xFFFF)
  52. #endif
  53.  
  54.   _CRTIMP wchar_t *_cgetws(wchar_t *_Buffer);
  55.   _CRTIMP wint_t __cdecl _getwch(void);
  56.   _CRTIMP wint_t __cdecl _getwche(void);
  57.   _CRTIMP wint_t __cdecl _putwch(wchar_t _WCh);
  58.   _CRTIMP wint_t __cdecl _ungetwch(wint_t _WCh);
  59.   _CRTIMP int __cdecl _cputws(const wchar_t *_String);
  60.   _CRTIMP int __cdecl _cwprintf(const wchar_t *_Format,...);
  61.   _CRTIMP int __cdecl _cwscanf(const wchar_t *_Format,...);
  62.   _CRTIMP int __cdecl _cwscanf_l(const wchar_t *_Format,_locale_t _Locale,...);
  63.   _CRTIMP int __cdecl _vcwprintf(const wchar_t *_Format,va_list _ArgList);
  64.   _CRTIMP int __cdecl _cwprintf_p(const wchar_t *_Format,...);
  65.   _CRTIMP int __cdecl _vcwprintf_p(const wchar_t *_Format,va_list _ArgList);
  66.   _CRTIMP int __cdecl _cwprintf_l(const wchar_t *_Format,_locale_t _Locale,...);
  67.   _CRTIMP int __cdecl _vcwprintf_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  68.   _CRTIMP int __cdecl _cwprintf_p_l(const wchar_t *_Format,_locale_t _Locale,...);
  69.   _CRTIMP int __cdecl _vcwprintf_p_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList);
  70.   _CRTIMP wint_t __cdecl _putwch_nolock(wchar_t _WCh);
  71.   _CRTIMP wint_t __cdecl _getwch_nolock(void);
  72.   _CRTIMP wint_t __cdecl _getwche_nolock(void);
  73.   _CRTIMP wint_t __cdecl _ungetwch_nolock(wint_t _WCh);
  74. #endif
  75.  
  76. #ifndef NO_OLDNAMES
  77.   char *__cdecl cgets(char *_Buffer);
  78.   int __cdecl cprintf(const char *_Format,...);
  79.   int __cdecl cputs(const char *_Str);
  80.   int __cdecl cscanf(const char *_Format,...);
  81.   int __cdecl getch(void);
  82.   int __cdecl getche(void);
  83.   int __cdecl kbhit(void);
  84.   int __cdecl putch(int _Ch);
  85.   int __cdecl ungetch(int _Ch);
  86.  
  87. #if (defined(_X86_) && !defined(__x86_64))
  88.   int __cdecl inp(unsigned short);
  89.   unsigned short __cdecl inpw(unsigned short);
  90.   int __cdecl outp(unsigned short,int);
  91.   unsigned short __cdecl outpw(unsigned short,unsigned short);
  92. #endif
  93.  
  94.   /* I/O intrin functions.  */
  95.   __CRT_INLINE unsigned char __inbyte(unsigned short Port)
  96.   {
  97.       unsigned char value;
  98.       __asm__ __volatile__ ("inb %w1,%b0"
  99.           : "=a" (value)
  100.           : "Nd" (Port));
  101.       return value;
  102.   }
  103.   __CRT_INLINE unsigned short __inword(unsigned short Port)
  104.   {
  105.       unsigned short value;
  106.       __asm__ __volatile__ ("inw %w1,%w0"
  107.           : "=a" (value)
  108.           : "Nd" (Port));
  109.       return value;
  110.   }
  111.   __CRT_INLINE unsigned long __indword(unsigned short Port)
  112.   {
  113.       unsigned long value;
  114.       __asm__ __volatile__ ("inl %w1,%0"
  115.           : "=a" (value)
  116.           : "Nd" (Port));
  117.       return value;
  118.   }
  119.   __CRT_INLINE void __outbyte(unsigned short Port,unsigned char Data)
  120.   {
  121.       __asm__ __volatile__ ("outb %b0,%w1"
  122.           :
  123.           : "a" (Data), "Nd" (Port));
  124.   }
  125.   __CRT_INLINE void __outword(unsigned short Port,unsigned short Data)
  126.   {
  127.       __asm__ __volatile__ ("outw %w0,%w1"
  128.           :
  129.           : "a" (Data), "Nd" (Port));
  130.   }
  131.   __CRT_INLINE void __outdword(unsigned short Port,unsigned long Data)
  132.   {
  133.       __asm__ __volatile__ ("outl %0,%w1"
  134.           :
  135.           : "a" (Data), "Nd" (Port));
  136.   }
  137.   __CRT_INLINE void __inbytestring(unsigned short Port,unsigned char *Buffer,unsigned long Count)
  138.   {
  139.         __asm__ __volatile__ (
  140.                 "cld ; rep ; insb "
  141.                 : "=D" (Buffer), "=c" (Count)
  142.                 : "d"(Port), "0"(Buffer), "1" (Count)
  143.                 );
  144.   }
  145.   __CRT_INLINE void __inwordstring(unsigned short Port,unsigned short *Buffer,unsigned long Count)
  146.   {
  147.         __asm__ __volatile__ (
  148.                 "cld ; rep ; insw "
  149.                 : "=D" (Buffer), "=c" (Count)
  150.                 : "d"(Port), "0"(Buffer), "1" (Count)
  151.                 );
  152.   }
  153.   __CRT_INLINE void __indwordstring(unsigned short Port,unsigned long *Buffer,unsigned long Count)
  154.   {
  155.         __asm__ __volatile__ (
  156.                 "cld ; rep ; insl "
  157.                 : "=D" (Buffer), "=c" (Count)
  158.                 : "d"(Port), "0"(Buffer), "1" (Count)
  159.                 );
  160.   }
  161.  
  162.   __CRT_INLINE void __outbytestring(unsigned short Port,unsigned char *Buffer,unsigned long Count)
  163.   {
  164.       __asm__ __volatile__ (
  165.           "cld ; rep ; outsb "
  166.           : "=S" (Buffer), "=c" (Count)
  167.           : "d"(Port), "0"(Buffer), "1" (Count)
  168.           );
  169.   }
  170.   __CRT_INLINE void __outwordstring(unsigned short Port,unsigned short *Buffer,unsigned long Count)
  171.   {
  172.       __asm__ __volatile__ (
  173.           "cld ; rep ; outsw "
  174.           : "=S" (Buffer), "=c" (Count)
  175.           : "d"(Port), "0"(Buffer), "1" (Count)
  176.           );
  177.   }
  178.   __CRT_INLINE void __outdwordstring(unsigned short Port,unsigned long *Buffer,unsigned long Count)
  179.   {
  180.       __asm__ __volatile__ (
  181.           "cld ; rep ; outsl "
  182.           : "=S" (Buffer), "=c" (Count)
  183.           : "d"(Port), "0"(Buffer), "1" (Count)
  184.           );
  185.   }
  186.  
  187.   __CRT_INLINE unsigned __int64 __readcr0(void)
  188.   {
  189.       unsigned __int64 value;
  190.       __asm__ __volatile__ (
  191.           "mov %%cr0, %[value]"
  192.           : [value] "=q" (value));
  193.       return value;
  194.   }
  195.  
  196.   /* Register sizes are different between 32/64 bit mode. So we have to do this for _WIN64 and _WIN32
  197.      seperatly.  */
  198.  
  199. #ifdef _WIN64
  200.   __CRT_INLINE void __writecr0(unsigned __int64 Data)
  201.   {
  202.    __asm__ __volatile__ (
  203.        "mov %[Data], %%cr0"
  204.        :
  205.        : [Data] "q" (Data)
  206.        : "memory");
  207.   }
  208.  
  209.   __CRT_INLINE unsigned __int64 __readcr2(void)
  210.   {
  211.       unsigned __int64 value;
  212.       __asm__ __volatile__ (
  213.           "mov %%cr2, %[value]"
  214.           : [value] "=q" (value));
  215.       return value;
  216.   }
  217.  
  218.  __CRT_INLINE void __writecr2(unsigned __int64 Data)
  219.  {
  220.    __asm__ __volatile__ (
  221.        "mov %[Data], %%cr2"
  222.        :
  223.        : [Data] "q" (Data)
  224.        : "memory");
  225.  }
  226.  
  227.   __CRT_INLINE unsigned __int64 __readcr3(void)
  228.   {
  229.       unsigned __int64 value;
  230.       __asm__ __volatile__ (
  231.           "mov %%cr3, %[value]"
  232.           : [value] "=q" (value));
  233.       return value;
  234.   }
  235.  
  236.  __CRT_INLINE void __writecr3(unsigned __int64 Data)
  237.  {
  238.    __asm__ __volatile__ (
  239.        "mov %[Data], %%cr3"
  240.        :
  241.        : [Data] "q" (Data)
  242.        : "memory");
  243.  }
  244.  
  245.   __CRT_INLINE unsigned __int64 __readcr4(void)
  246.   {
  247.       unsigned __int64 value;
  248.       __asm__ __volatile__ (
  249.           "mov %%cr4, %[value]"
  250.           : [value] "=q" (value));
  251.       return value;
  252.   }
  253.  
  254.  __CRT_INLINE void __writecr4(unsigned __int64 Data)
  255.  {
  256.      __asm__ __volatile__ (
  257.          "mov %[Data], %%cr4"
  258.          :
  259.          : [Data] "q" (Data)
  260.          : "memory");
  261.  }
  262.  
  263.   __CRT_INLINE unsigned __int64 __readcr8(void)
  264.   {
  265.       unsigned __int64 value;
  266.       __asm__ __volatile__ (
  267.           "mov %%cr8, %[value]"
  268.           : [value] "=q" (value));
  269.       return value;
  270.   }
  271.  
  272.  __CRT_INLINE void __writecr8(unsigned __int64 Data)
  273.  {
  274.    __asm__ __volatile__ (
  275.        "mov %[Data], %%cr8"
  276.        :
  277.        : [Data] "q" (Data)
  278.        : "memory");
  279.  }
  280.  
  281. #elif defined(_WIN32)
  282.  
  283.   __CRT_INLINE void __writecr0(unsigned Data)
  284.   {
  285.     __asm__ __volatile__ (
  286.        "mov %[Data], %%cr0"
  287.        :
  288.        : [Data] "q" (Data)
  289.        : "memory");
  290.   }
  291.  
  292.   __CRT_INLINE unsigned long __readcr2(void)
  293.   {
  294.       unsigned long value;
  295.       __asm__ __volatile__ (
  296.           "mov %%cr2, %[value]"
  297.           : [value] "=q" (value));
  298.       return value;
  299.   }
  300.  
  301.  __CRT_INLINE void __writecr2(unsigned Data)
  302.  {
  303.    __asm__ __volatile__ (
  304.        "mov %[Data], %%cr2"
  305.        :
  306.        : [Data] "q" (Data)
  307.        : "memory");
  308.  }
  309.  
  310.   __CRT_INLINE unsigned long __readcr3(void)
  311.   {
  312.       unsigned long value;
  313.       __asm__ __volatile__ (
  314.           "mov %%cr3, %[value]"
  315.           : [value] "=q" (value));
  316.       return value;
  317.   }
  318.  
  319.  __CRT_INLINE void __writecr3(unsigned Data)
  320.  {
  321.    __asm__ __volatile__ (
  322.        "mov %[Data], %%cr3"
  323.        :
  324.        : [Data] "q" (Data)
  325.        : "memory");
  326.  }
  327.  
  328.   __CRT_INLINE unsigned long __readcr4(void)
  329.   {
  330.       unsigned long value;
  331.       __asm__ __volatile__ (
  332.           "mov %%cr4, %[value]"
  333.           : [value] "=q" (value));
  334.       return value;
  335.   }
  336.  
  337.  __CRT_INLINE void __writecr4(unsigned Data)
  338.  {
  339.      __asm__ __volatile__ (
  340.          "mov %[Data], %%cr4"
  341.          :
  342.          : [Data] "q" (Data)
  343.          : "memory");
  344.  }
  345.  
  346.  __CRT_INLINE unsigned long __readcr8(void)
  347.  {
  348.    unsigned long value;      __asm__ __volatile__ (
  349.           "mov %%cr8, %[value]"
  350.           : [value] "=q" (value));
  351.      return value;
  352.  }
  353.  
  354.  __CRT_INLINE void __writecr8(unsigned Data)
  355.  {
  356.    __asm__ __volatile__ (
  357.        "mov %[Data], %%cr8"
  358.        :
  359.        : [Data] "q" (Data)
  360.        : "memory");
  361.  }
  362.  
  363. #endif
  364.  
  365.   __CRT_INLINE unsigned __int64 __readmsr(unsigned long msr)
  366.   {
  367.       unsigned __int64 val1, val2;
  368.        __asm__ __volatile__(
  369.            "rdmsr"
  370.            : "=a" (val1), "=d" (val2)
  371.            : "c" (msr));
  372.       return val1 | (val2 << 32);
  373.   }
  374.  
  375.  __CRT_INLINE void __writemsr (unsigned long msr, unsigned __int64 Value)
  376.  {
  377.     unsigned long val1 = Value, val2 = Value >> 32;
  378.    __asm__ __volatile__ (
  379.        "wrmsr"
  380.        :
  381.        : "c" (msr), "a" (val1), "d" (val2));
  382.  }
  383.  
  384.   __CRT_INLINE unsigned __int64 __rdtsc(void)
  385.   {
  386.       unsigned __int64 val1, val2;
  387.       __asm__ __volatile__ (
  388.           "rdtsc"
  389.           : "=a" (val1), "=d" (val2));
  390.       return val1 | (val2 << 32);
  391.   }
  392.  
  393.   __CRT_INLINE void __cpuid(int CPUInfo[4], int InfoType)
  394.   {
  395.       __asm__ __volatile__ (
  396.           "cpuid"
  397.           : "=a" (CPUInfo [0]), "=b" (CPUInfo [1]), "=c" (CPUInfo [2]), "=d" (CPUInfo [3])
  398.           : "a" (InfoType));
  399.   }
  400.  
  401. #endif
  402.  
  403. #ifdef __cplusplus
  404. }
  405. #endif
  406.  
  407. #include <sec_api/conio_s.h>
  408.  
  409. #endif
  410.