For DOS Protected Mode version of sensor core software
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

563 lines
16 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "hardware.h"
  2. int getDriveGeometry( unsigned char DriveID, CHS_DRIVE_GEOMETRY *ptr ){
  3. if( ptr == NULL ) return -1;
  4. __dpmi_regs r;
  5. r.h.ah = DriveID;
  6. __dpmi_int( 0x13, &r );
  7. printf( "Drive[0x%02X] Geometry Data\nAX: 0x%04X\nBX: 0x%04X\nCX: 0x%04X\nDX: 0x%04X\n", DriveID, r.x.ax, r.x.bx, r.x.cx, r.x.dx );
  8. /*
  9. BL = drive type (AT/PS2 floppies only) (see #00242)
  10. CH = low eight bits of maximum cylinder number
  11. CL = maximum sector number (bits 5-0)
  12. high two bits of maximum cylinder number (bits 7-6)
  13. DH = maximum head number
  14. DL = number of drives */
  15. ptr->drive_type = r.h.bl;
  16. ptr->max_drives = r.h.dl;
  17. ptr->c = ( r.h.cl >> 6 ) | r.h.ch;
  18. ptr->s = r.h.cl & 0x3F;
  19. ptr->h = r.h.dh;
  20. printf("Drive [%d] info (C:%d,H:%d,S:%d) mas drives:%d\n",
  21. ptr->drive_type,
  22. ptr->c,
  23. ptr->h,
  24. ptr->s,
  25. ptr->max_drives
  26. );
  27. return 0;
  28. };
  29. /*
  30. 00 dword 32 bit starting sector
  31. 04 word number of sectors to read
  32. 06 word pointer to offset of buffer
  33. 08 word pointer to segment of buffer
  34. */
  35. #ifdef __cplusplus
  36. #pragma pack(1)
  37. #endif
  38. typedef struct S_DOS_IO_CTL_BLOCK{
  39. uint32_t start_sector;
  40. uint16_t num_sectors;
  41. uint32_t buffer_ptr;
  42. }DOS_IO_CTL_BLOCK;
  43. int absread( int diskID, int nsects, long lsect, void *buffer ){
  44. /*
  45. int16_t 25 - Absolute Disk Read
  46. AL = logical drive number (0=A:, 1=B:, 2=C:, ...)
  47. CX = number of sectors to read
  48. = -1 if DOS 4.x (control block pointer is in DS:BX)
  49. DX = starting logical sector number (see below for DOS 4.x+)
  50. DS:BX = pointer to data buffer OR pointer to control block (DOS 4.x+, see below)
  51. on return:
  52. AH = error code if CF set:
  53. 01 bad command
  54. 02 bad address mark
  55. 03 write protect
  56. 04 sector not found
  57. 08 DMA failure
  58. 10 data error (bad CRC)
  59. 20 controller failed
  60. 40 seek failed
  61. 80 attachment failed to respond
  62. AL = BIOS error code if CF set
  63. 00 write protect error
  64. 01 unknown unit
  65. 02 drive not ready
  66. 03 unknown command
  67. 04 data error (bad CRC)
  68. 05 bad request structure length
  69. 06 seek error
  70. 07 unknown media type
  71. 08 sector not found
  72. 0A write fault
  73. 0B read fault
  74. 0C general failure
  75. Control Block Format (DOS 4.x):
  76. Offset Size Description
  77. 00 dword starting sector
  78. 04 word number of sectors to read
  79. 06 dword pointer to buffer
  80. - reads disk sectors into buffer at DS:BX or DS:[BX+6]
  81. - after calling this interrupt the flags register remains on the
  82. stack and must be popped manually
  83. - sectors are logical sectors starting at the beginning of a
  84. logical disk; each DOS partition on a drive unit is considered
  85. one logical drive and has it's own logical sector numbers with
  86. track 0 starting at the first track in the partition
  87. - this function uses logical drives, and is susceptible to ASSIGN
  88. - physical sector numbers can be converted to and from DOS sector
  89. numbers with the following formulas:
  90. dos_sector = (sector - 1) + (head * sectors_per_track) +
  91. (track * sectors_per_track * num_heads)
  92. physical_sector = 1 + (dos_sector MOD sectors_per_track)
  93. physical_head = (dos_sector / sectors_per_track) MOD num_heads
  94. physical_track = dos_sector / (sectors_per_track * num_heads)
  95. */
  96. __dpmi_regs r;
  97. int tLA = 0;
  98. int dos_segment = 0;
  99. int dos_selector = 0;
  100. DOS_IO_CTL_BLOCK ctlBock;
  101. r.h.al = diskID & 0xff;
  102. r.x.cx = 0xFFFF;
  103. ctlBock.num_sectors = nsects;
  104. ctlBock.start_sector = lsect;
  105. if( ( nsects * 512 ) > __tb_size ){
  106. dos_segment = __dpmi_allocate_dos_memory( ((( nsects * 512 + sizeof(DOS_IO_CTL_BLOCK) )+15)>>4), &dos_selector );
  107. if( dos_segment == 0 ) return -1; /* undefined error */
  108. r.x.ds = dos_segment;
  109. r.x.bx = 0;
  110. tLA = r.x.ds << 4;
  111. } else {
  112. tLA = __tb;
  113. r.x.ds = tLA >> 4;
  114. r.x.bx = tLA & 0xf;
  115. };
  116. ctlBock.buffer_ptr = ((( tLA + sizeof( DOS_IO_CTL_BLOCK ) ) >> 4 ) << 16 ) | (( tLA + sizeof( DOS_IO_CTL_BLOCK ) ) & 0xf );
  117. dosmemput( (void *) &ctlBock, sizeof(DOS_IO_CTL_BLOCK), tLA );
  118. if( __dpmi_int( 0x25, &r ) == 0 && ( r.x.flags & 1 ) == 0 ){
  119. dosmemget( tLA+sizeof(DOS_IO_CTL_BLOCK), 512*nsects, buffer );
  120. if( dos_segment ) __dpmi_free_dos_memory( dos_selector );
  121. } else {
  122. printf( "Dos Error:");
  123. switch( r.h.ah ) {
  124. case 0x01: printf("bad command\n"); break;
  125. case 0x02: printf("bad address mark\n"); break;
  126. case 0x03: printf("write protect\n"); break;
  127. case 0x04: printf("sector not found\n"); break;
  128. case 0x08: printf("DMA failure\n"); break;
  129. case 0x10: printf("data error (bad CRC)\n"); break;
  130. case 0x20: printf("controller failed\n"); break;
  131. case 0x40: printf("seek failed\n"); break;
  132. case 0x80: printf("attachment failed to respond\n"); break;
  133. };
  134. printf( "BIOS Error:");
  135. switch( r.h.ah ) {
  136. case 0x00: printf("write protect error\n"); break;
  137. case 0x01: printf("unknown unit\n"); break;
  138. case 0x02: printf("drive not ready\n"); break;
  139. case 0x03: printf("unknown command\n"); break;
  140. case 0x04: printf("data error (bad CRC)\n"); break;
  141. case 0x05: printf("bad request structure length\n"); break;
  142. case 0x06: printf("seek error\n"); break;
  143. case 0x07: printf("unknown media type\n"); break;
  144. case 0x08: printf("sector not found\n"); break;
  145. case 0x0A: printf("write fault\n"); break;
  146. case 0x0B: printf("read fault\n"); break;
  147. case 0x0C: printf("general failure\n"); break;
  148. };
  149. if( dos_segment ) __dpmi_free_dos_memory( dos_selector );
  150. return -1;
  151. };
  152. return 0;
  153. };
  154. /*
  155. int16_t 26 - Absolute Disk Write
  156. AL = logical drive number (0=A:, 1=B:, 2=C:, ...)
  157. CX = number of sectors to write
  158. = -1 if DOS 4.x (control block pointer is in DS:BX)
  159. DX = starting logical sector number (see below for DOS 4.x+)
  160. DS:BX = pointer to data buffer
  161. = pointer to control block (DOS 4.x+, see below)
  162. on return:
  163. AH = error code if CF set:
  164. 01 bad command
  165. 02 bad address mark
  166. 03 write protect
  167. 04 sector not found
  168. 08 DMA failure
  169. 10 data error (bad CRC)
  170. 20 controller failed
  171. 40 seek failed
  172. 80 attachment failed to respond
  173. AL = BIOS error code if CF set
  174. 00 write protect error
  175. 01 unknown unit
  176. 02 drive not ready
  177. 03 unknown command
  178. 04 data error (bad CRC)
  179. 05 bad request structure length
  180. 06 seek error
  181. 07 unknown media type
  182. 08 sector not found
  183. 0A write fault
  184. 0B read fault
  185. 0C general failure
  186. Control Block Format (DOS 4.x):
  187. Offset Size Description
  188. 00 dword starting sector
  189. 04 word number of sectors to write
  190. 06 dword pointer to buffer
  191. - writes disk sectors from buffer at DS:BX or DS:[BX+6]
  192. - after calling this interrupt the flags register remains on the
  193. stack and must be popped manually
  194. - sectors are logical sectors starting at the beginning of a
  195. logical disk; each DOS partition on a drive unit is considered
  196. one logical drive and has it's own logical sector numbers with
  197. track 0 starting at the first track in the partition
  198. - this function uses logical drives, and is susceptible to ASSIGN
  199. - physical sector numbers can be converted to and from DOS sector
  200. numbers with the following formulas:
  201. dos_sector = (sector - 1) + (head * sectors_per_track) +
  202. (track * sectors_per_track * num_heads)
  203. physical_sector = 1 + (dos_sector MOD sectors_per_track)
  204. physical_head = (dos_sector / sectors_per_track) MOD num_heads
  205. physical_track = dos_sector / (sectors_per_track * num_heads)
  206. */
  207. int abswrite(int diskID, int nsects, long lsect, void *buffer ){
  208. if( buffer == NULL ) return -1;
  209. __dpmi_regs r;
  210. int tLA = 0;
  211. int dos_segment = 0;
  212. int dos_selector = 0;
  213. DOS_IO_CTL_BLOCK ctlBock;
  214. r.h.al = diskID & 0xff;
  215. r.x.cx = 0xFFFF;//nsects;
  216. //r.x.dx = lsect;
  217. ctlBock.num_sectors = nsects;
  218. ctlBock.start_sector = lsect;
  219. if( ( nsects * 512 ) > __tb_size ){
  220. dos_segment = __dpmi_allocate_dos_memory( ((( nsects * 512 )+15)>>4), &dos_selector );
  221. if( dos_segment == 0 ) return -1; /* undefined error */
  222. r.x.ds = dos_segment;
  223. r.x.bx = 0;
  224. tLA = r.x.ds << 4;
  225. } else {
  226. tLA = __tb;
  227. r.x.ds = tLA >> 4;
  228. r.x.bx = tLA & 0xf;
  229. };
  230. ctlBock.buffer_ptr = ((( tLA + sizeof( DOS_IO_CTL_BLOCK ) ) >> 4 ) << 16 ) | (( tLA + sizeof( DOS_IO_CTL_BLOCK ) ) & 0xf );
  231. dosmemput( (void *) &ctlBock, sizeof(DOS_IO_CTL_BLOCK), tLA );
  232. dosmemput( buffer, 512*nsects, tLA+sizeof(DOS_IO_CTL_BLOCK) );
  233. if( __dpmi_int( 0x26, &r ) == 0 && ( r.x.flags & 1 ) == 0 ){
  234. if( dos_segment ) __dpmi_free_dos_memory( dos_selector );
  235. } else {
  236. printf( "Dos Error:");
  237. switch( r.h.ah ) {
  238. case 0x01: printf("bad command\n"); break;
  239. case 0x02: printf("bad address mark\n"); break;
  240. case 0x03: printf("write protect\n"); break;
  241. case 0x04: printf("sector not found\n"); break;
  242. case 0x08: printf("DMA failure\n"); break;
  243. case 0x10: printf("data error (bad CRC)\n"); break;
  244. case 0x20: printf("controller failed\n"); break;
  245. case 0x40: printf("seek failed\n"); break;
  246. case 0x80: printf("attachment failed to respond\n"); break;
  247. };
  248. printf( "BIOS Error:");
  249. switch( r.h.ah ) {
  250. case 0x00: printf("write protect error\n"); break;
  251. case 0x01: printf("unknown unit\n"); break;
  252. case 0x02: printf("drive not ready\n"); break;
  253. case 0x03: printf("unknown command\n"); break;
  254. case 0x04: printf("data error (bad CRC)\n"); break;
  255. case 0x05: printf("bad request structure length\n"); break;
  256. case 0x06: printf("seek error\n"); break;
  257. case 0x07: printf("unknown media type\n"); break;
  258. case 0x08: printf("sector not found\n"); break;
  259. case 0x0A: printf("write fault\n"); break;
  260. case 0x0B: printf("read fault\n"); break;
  261. case 0x0C: printf("general failure\n"); break;
  262. };
  263. if( dos_segment ) __dpmi_free_dos_memory( dos_selector );
  264. return -1;
  265. };
  266. return 0;
  267. };
  268. /*!
  269. \arg \c idx number of 32x port.
  270. \details Reads North bridge register. The \a idx is port number to read 32 bit value from.
  271. */
  272. unsigned long read_nb(unsigned char idx){
  273. unsigned long retval;
  274. #ifdef __DJGPP__
  275. // https://www.dsl-ltd.co.uk/applications/accessing-north-bridge-south-bridge-registers-vortex86/
  276. outportl( 0xcf8, ( 0x80000000L | idx ) );
  277. retval = inportl( 0xcfc );
  278. #else
  279. _asm mov dx, 0cf8h
  280. __emit__(0x66); __emit__(0xb8);
  281. __emit__(0x00); __emit__(0x00); __emit__(0x00); __emit__(0x80);
  282. _asm mov al, idx
  283. __emit__(0x66); _asm out dx, ax
  284. _asm mov dx, 0cfch
  285. __emit__(0x66); _asm in ax, dx
  286. __emit__(0x66); _asm mov uint16_t PTR retval, ax
  287. #endif
  288. return retval;
  289. };
  290. // Write north bridge register
  291. void write_nb(unsigned char idx, unsigned long val){
  292. #ifdef __DJGPP__
  293. #else
  294. _asm mov dx, 0cf8h
  295. __emit__(0x66); __emit__(0xb8);
  296. __emit__(0x00); __emit__(0x00); __emit__(0x00); __emit__(0x80);
  297. _asm mov al, idx
  298. __emit__(0x66); __emit__(0xef);
  299. _asm mov dx, 0cfch
  300. __emit__(0x66); __emit__(0x8b); __emit__(0x46); __emit__(0x08);
  301. __emit__(0x66); __emit__(0xef);
  302. #endif
  303. };
  304. // Read south bridge register
  305. unsigned long read_sb(unsigned char idx){
  306. unsigned long retval;
  307. #ifdef __DJGPP__
  308. #else
  309. _asm mov dx, 0cf8h
  310. //80009000h
  311. // mov eax, 80003800h
  312. __emit__(0x66); __emit__(0xb8);
  313. //__emit__(0x00); __emit__(0x38); __emit__(0x00); __emit__(0x80);
  314. __emit__(0x00); __emit__(0x90); __emit__(0x00); __emit__(0x80);
  315. _asm mov al, idx
  316. // out edx, eax
  317. __emit__(0x66); _asm out dx, ax
  318. _asm mov dx, 0cfch
  319. // in eax, edx
  320. __emit__(0x66); _asm in ax, dx
  321. // mov retval, eax
  322. __emit__(0x66); _asm mov uint16_t PTR retval, ax
  323. #endif
  324. return retval;
  325. };
  326. // Write south bridge register
  327. /*void write_sb(unsigned char idx, unsigned long val){
  328. __asm{
  329. mov dx, 0cf8h
  330. mov eax, 80009000h
  331. mov al, idx
  332. out dx, eax
  333. mov dx, 0cfch
  334. mov eax, DWORD PTR val
  335. out dx, eax
  336. }
  337. };
  338. */
  339. void make_ws8( void ){
  340. unsigned long retval;
  341. #ifdef __DJGPP__
  342. #else
  343. _asm mov dx, 0cf8h
  344. __emit__(0x66); __emit__(0xb8);
  345. __emit__(0x50); __emit__(0x90); __emit__(0x00); __emit__(0x80);
  346. __emit__(0x66); _asm out dx, ax
  347. _asm mov dx, 0cfch
  348. __emit__(0x66); _asm in ax, dx
  349. __emit__(0x66); _asm mov uint16_t PTR retval, ax
  350. retval = retval | 0x0000F000UL;
  351. _asm mov dx, 0cf8h
  352. __emit__(0x66); __emit__(0xb8);
  353. __emit__(0x50); __emit__(0x90); __emit__(0x00); __emit__(0x80);
  354. __emit__(0x66); _asm out dx, ax
  355. _asm mov dx, 0cfch
  356. __emit__(0x66); _asm mov ax, uint16_t PTR retval
  357. __emit__(0x66); _asm out dx, ax
  358. #endif
  359. };
  360. // Write south bridge register
  361. void write_sb( unsigned char idx, unsigned long val ){
  362. #ifdef __DJGPP__
  363. #else
  364. _asm mov dx, 0cf8h
  365. //80009000h
  366. // mov eax, 80003800h
  367. __emit__(0x66); __emit__(0xb8);
  368. //__emit__(0x00); __emit__(0x38); __emit__(0x00); __emit__(0x80);
  369. __emit__(0x00); __emit__(0x90); __emit__(0x00); __emit__(0x80);
  370. _asm mov al, idx
  371. // out dx, eax
  372. __emit__(0x66); __emit__(0xef);
  373. _asm mov dx, 0cfch
  374. // mov eax, val
  375. __emit__(0x66); __emit__(0x8b); __emit__(0x46); __emit__(0x08);
  376. // out dx, eax
  377. __emit__(0x66); __emit__(0xef);
  378. #endif
  379. };
  380. unsigned char read_sbb( unsigned char idx ){
  381. unsigned char retval;
  382. #ifdef __DJGPP__
  383. #else
  384. _asm mov dx, 0cf8h
  385. // mov eax, 80009000h
  386. __emit__(0x66); __emit__(0xb8);
  387. __emit__(0x00); __emit__(0x90); __emit__(0x00); __emit__(0x80);
  388. _asm mov al, idx
  389. // out edx, eax
  390. //__emit__(0x66); __emit__(0xef);
  391. __emit__(0x66); _asm out dx, ax
  392. /*_asm mov dx, 0cfch
  393. // in eax, edx
  394. __emit__(0x66); _asm in al, dx
  395. // mov retval, eax
  396. __emit__(0x66); _asm mov uint8_t PTR retval, al
  397. */
  398. retval = inportb( 0x0CFC );
  399. #endif
  400. return retval;
  401. };
  402. unsigned int read_sbw( unsigned char idx ){
  403. unsigned int retval;
  404. #ifdef __DJGPP__
  405. #else
  406. _asm mov dx, 0cf8h
  407. // mov eax, 80009000h
  408. __emit__(0x66); __emit__(0xb8);
  409. __emit__(0x00); __emit__(0x90); __emit__(0x00); __emit__(0x80);
  410. _asm mov al, idx
  411. // out edx, eax
  412. //__emit__(0x66); __emit__(0xef);
  413. __emit__(0x66); _asm out dx, ax
  414. /*_asm mov dx, 0cfch
  415. // in eax, edx
  416. __emit__(0x66); _asm in al, dx
  417. // mov retval, eax
  418. __emit__(0x66); _asm mov uint8_t PTR retval, al
  419. */
  420. retval = inport( 0x0CFC );
  421. #endif
  422. return retval;
  423. };
  424. // Write south bridge register
  425. void write_sbb( unsigned char idx, unsigned char val ){
  426. #ifdef __DJGPP__
  427. #else
  428. _asm mov dx, 0cf8h
  429. //80009000h
  430. // mov eax, 80003800h
  431. __emit__(0x66); __emit__(0xb8);
  432. //__emit__(0x00); __emit__(0x38); __emit__(0x00); __emit__(0x80);
  433. __emit__(0x00); __emit__(0x90); __emit__(0x00); __emit__(0x80);
  434. _asm mov al, idx
  435. // out dx, eax
  436. __emit__(0x66); __emit__(0xef);
  437. outportb( 0x0CFC, val );
  438. /*_asm mov dx, 0cfch
  439. // mov eax, val
  440. __emit__(0x66); __emit__(0x8b); __emit__(0x46); __emit__(0x08);
  441. // out dx, eax
  442. __emit__(0x66); __emit__(0xef);*/
  443. #endif
  444. };
  445. #define ZFLINDEX 0x0218
  446. #define ZFLDATA8 0x0219
  447. #define ZFLDATA16 0x021A
  448. void ZFLWriteb( unsigned char index, unsigned char value ){
  449. outportb( ZFLINDEX, index );
  450. outportb( ZFLDATA8, value );
  451. /*asm
  452. {
  453. mov AL,index
  454. mov DX,ZFLINDEX
  455. out DX,AL
  456. mov DX,ZFLDATA8
  457. mov AL,value
  458. out DX,AL
  459. }*/
  460. };
  461. void ZFLWritew( unsigned char index, unsigned int value ){
  462. outportb( ZFLINDEX, index );
  463. outportw( ZFLDATA16, value );
  464. /* asm
  465. {
  466. mov AL,index
  467. mov DX,ZFLINDEX
  468. out DX,AL
  469. mov DX,ZFLDATA16
  470. mov AX,value
  471. out DX,AX
  472. } */
  473. };
  474. unsigned char ZFLReadb( unsigned char index ){
  475. outportb( ZFLINDEX, index );
  476. return inportb( ZFLDATA8 );
  477. /* asm
  478. {
  479. mov AL,index
  480. mov DX,ZFLINDEX
  481. out DX,AL
  482. mov DX,ZFLDATA8
  483. in AL,DX
  484. }
  485. return _AL;
  486. */
  487. };
  488. unsigned int ZFLReadw( unsigned char index ){
  489. outportb( ZFLINDEX, index );
  490. return inportw( ZFLDATA16 );
  491. };
  492. void ZFLOrb( unsigned char index, unsigned char mask ){
  493. /*asm
  494. {
  495. mov AL,index
  496. mov DX,ZFLINDEX
  497. out DX,AL
  498. mov DX,ZFLDATA8
  499. in AL,DX
  500. or AL,mask
  501. out DX,AL
  502. }*/
  503. outportb( ZFLDATA8, ZFLReadb(index) | mask );
  504. };
  505. uint64_t rdtsc( void ){
  506. uint32_t low, high;
  507. asm volatile("rdtsc":"=a"(low),"=d"(high));
  508. return ((uint64_t)high << 32) | low;
  509. }
  510. #ifdef __cplusplus
  511. #pragma pack()
  512. #endif