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.

librm.S 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /*
  2. * librm: a library for interfacing to real-mode code
  3. *
  4. * Michael Brown <mbrown@fensystems.co.uk>
  5. *
  6. */
  7. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
  8. /* Drag in local definitions */
  9. #include "librm.h"
  10. /* For switches to/from protected mode */
  11. #define CR0_PE 1
  12. /* Size of various C data structures */
  13. #define SIZEOF_I386_SEG_REGS 12
  14. #define SIZEOF_I386_REGS 32
  15. #define SIZEOF_REAL_MODE_REGS ( SIZEOF_I386_SEG_REGS + SIZEOF_I386_REGS )
  16. #define SIZEOF_I386_FLAGS 4
  17. #define SIZEOF_I386_ALL_REGS ( SIZEOF_REAL_MODE_REGS + SIZEOF_I386_FLAGS )
  18. .arch i386
  19. /****************************************************************************
  20. * Global descriptor table
  21. *
  22. * Call init_librm to set up the GDT before attempting to use any
  23. * protected-mode code.
  24. *
  25. * NOTE: This must be located before prot_to_real, otherwise gas
  26. * throws a "can't handle non absolute segment in `ljmp'" error due to
  27. * not knowing the value of REAL_CS when the ljmp is encountered.
  28. *
  29. * Note also that putting ".word gdt_end - gdt - 1" directly into
  30. * gdt_limit, rather than going via gdt_length, will also produce the
  31. * "non absolute segment" error. This is most probably a bug in gas.
  32. ****************************************************************************
  33. */
  34. .section ".data16.gdt", "aw", @progbits
  35. .align 16
  36. gdt:
  37. gdtr: /* The first GDT entry is unused, the GDTR can fit here. */
  38. gdt_limit: .word gdt_length - 1
  39. gdt_base: .long 0
  40. .word 0 /* padding */
  41. .org gdt + VIRTUAL_CS, 0
  42. virtual_cs: /* 32 bit protected mode code segment, virtual addresses */
  43. .word 0xffff, 0
  44. .byte 0, 0x9f, 0xcf, 0
  45. .org gdt + VIRTUAL_DS, 0
  46. virtual_ds: /* 32 bit protected mode data segment, virtual addresses */
  47. .word 0xffff, 0
  48. .byte 0, 0x93, 0xcf, 0
  49. .org gdt + PHYSICAL_CS, 0
  50. physical_cs: /* 32 bit protected mode code segment, physical addresses */
  51. .word 0xffff, 0
  52. .byte 0, 0x9f, 0xcf, 0
  53. .org gdt + PHYSICAL_DS, 0
  54. physical_ds: /* 32 bit protected mode data segment, physical addresses */
  55. .word 0xffff, 0
  56. .byte 0, 0x93, 0xcf, 0
  57. .org gdt + REAL_CS, 0
  58. real_cs: /* 16 bit real mode code segment */
  59. .word 0xffff, 0
  60. .byte 0, 0x9b, 0x00, 0
  61. .org gdt + REAL_DS
  62. real_ds: /* 16 bit real mode data segment */
  63. .word 0xffff, ( REAL_DS << 4 )
  64. .byte 0, 0x93, 0x00, 0
  65. gdt_end:
  66. .equ gdt_length, gdt_end - gdt
  67. /****************************************************************************
  68. * init_librm (real-mode far call, 16-bit real-mode far return address)
  69. *
  70. * Initialise the GDT ready for transitions to protected mode.
  71. *
  72. * Parameters:
  73. * %cs : .text16 segment
  74. * %ds : .data16 segment
  75. * %edi : Physical base of protected-mode code (virt_offset)
  76. ****************************************************************************
  77. */
  78. .section ".text16.init_librm", "ax", @progbits
  79. .code16
  80. .globl init_librm
  81. init_librm:
  82. /* Preserve registers */
  83. pushl %eax
  84. pushl %ebx
  85. /* Store virt_offset and set up virtual_cs and virtual_ds segments */
  86. movl %edi, %eax
  87. movw $virtual_cs, %bx
  88. call set_seg_base
  89. movw $virtual_ds, %bx
  90. call set_seg_base
  91. movl %edi, rm_virt_offset
  92. /* Negate virt_offset */
  93. negl %edi
  94. /* Store rm_cs and text16, set up real_cs segment */
  95. xorl %eax, %eax
  96. movw %cs, %ax
  97. movw %ax, %cs:rm_cs
  98. shll $4, %eax
  99. movw $real_cs, %bx
  100. call set_seg_base
  101. addr32 leal (%eax, %edi), %ebx
  102. movl %ebx, rm_text16
  103. /* Store rm_ds and data16 */
  104. xorl %eax, %eax
  105. movw %ds, %ax
  106. movw %ax, %cs:rm_ds
  107. shll $4, %eax
  108. addr32 leal (%eax, %edi), %ebx
  109. movl %ebx, rm_data16
  110. /* Set GDT base */
  111. movl %eax, gdt_base
  112. addl $gdt, gdt_base
  113. /* Initialise IDT */
  114. virtcall init_idt
  115. /* Restore registers */
  116. negl %edi
  117. popl %ebx
  118. popl %eax
  119. lret
  120. .section ".text16.set_seg_base", "ax", @progbits
  121. .code16
  122. set_seg_base:
  123. 1: movw %ax, 2(%bx)
  124. rorl $16, %eax
  125. movb %al, 4(%bx)
  126. movb %ah, 7(%bx)
  127. roll $16, %eax
  128. ret
  129. /****************************************************************************
  130. * real_to_prot (real-mode near call, 32-bit virtual return address)
  131. *
  132. * Switch from 16-bit real-mode to 32-bit protected mode with virtual
  133. * addresses. The real-mode %ss:sp is stored in rm_ss and rm_sp, and
  134. * the protected-mode %esp is restored from the saved pm_esp.
  135. * Interrupts are disabled. All other registers may be destroyed.
  136. *
  137. * The return address for this function should be a 32-bit virtual
  138. * address.
  139. *
  140. * Parameters:
  141. * %ecx : number of bytes to move from RM stack to PM stack
  142. *
  143. ****************************************************************************
  144. */
  145. .section ".text16.real_to_prot", "ax", @progbits
  146. .code16
  147. real_to_prot:
  148. /* Enable A20 line */
  149. call enable_a20
  150. /* A failure at this point is fatal, and there's nothing we
  151. * can do about it other than lock the machine to make the
  152. * problem immediately visible.
  153. */
  154. 1: jc 1b
  155. /* Make sure we have our data segment available */
  156. movw %cs:rm_ds, %ax
  157. movw %ax, %ds
  158. /* Add virt_offset, text16 and data16 to stack to be
  159. * copied, and also copy the return address.
  160. */
  161. pushl rm_virt_offset
  162. pushl rm_text16
  163. pushl rm_data16
  164. addw $16, %cx /* %ecx must be less than 64kB anyway */
  165. /* Real-mode %ss:%sp => %ebp:%edx and virtual address => %esi */
  166. xorl %ebp, %ebp
  167. movw %ss, %bp
  168. movzwl %sp, %edx
  169. movl %ebp, %eax
  170. shll $4, %eax
  171. addr32 leal (%eax,%edx), %esi
  172. subl rm_virt_offset, %esi
  173. /* Load protected-mode global descriptor table */
  174. data32 lgdt gdtr
  175. /* Zero segment registers. This wastes around 12 cycles on
  176. * real hardware, but saves a substantial number of emulated
  177. * instructions under KVM.
  178. */
  179. xorw %ax, %ax
  180. movw %ax, %ds
  181. movw %ax, %es
  182. movw %ax, %fs
  183. movw %ax, %gs
  184. movw %ax, %ss
  185. /* Switch to protected mode */
  186. cli
  187. movl %cr0, %eax
  188. orb $CR0_PE, %al
  189. movl %eax, %cr0
  190. data32 ljmp $VIRTUAL_CS, $r2p_pmode
  191. .section ".text.real_to_prot", "ax", @progbits
  192. .code32
  193. r2p_pmode:
  194. /* Set up protected-mode data segments and stack pointer */
  195. movw $VIRTUAL_DS, %ax
  196. movw %ax, %ds
  197. movw %ax, %es
  198. movw %ax, %fs
  199. movw %ax, %gs
  200. movw %ax, %ss
  201. movl pm_esp, %esp
  202. /* Load protected-mode interrupt descriptor table */
  203. lidt idtr
  204. /* Record real-mode %ss:sp (after removal of data) */
  205. movw %bp, rm_ss
  206. addl %ecx, %edx
  207. movw %dx, rm_sp
  208. /* Move data from RM stack to PM stack */
  209. subl %ecx, %esp
  210. movl %esp, %edi
  211. rep movsb
  212. /* Publish virt_offset, text16 and data16 for PM code to use */
  213. popl data16
  214. popl text16
  215. popl virt_offset
  216. /* Return to virtual address */
  217. ret
  218. /****************************************************************************
  219. * prot_to_real (protected-mode near call, 32-bit real-mode return address)
  220. *
  221. * Switch from 32-bit protected mode with virtual addresses to 16-bit
  222. * real mode. The protected-mode %esp is stored in pm_esp and the
  223. * real-mode %ss:sp is restored from the saved rm_ss and rm_sp. The
  224. * high word of the real-mode %esp is set to zero. All real-mode data
  225. * segment registers are loaded from the saved rm_ds. Interrupts are
  226. * *not* enabled, since we want to be able to use prot_to_real in an
  227. * ISR. All other registers may be destroyed.
  228. *
  229. * The return address for this function should be a 32-bit (sic)
  230. * real-mode offset within .code16.
  231. *
  232. * Parameters:
  233. * %ecx : number of bytes to move from PM stack to RM stack
  234. * %esi : real-mode global and interrupt descriptor table registers
  235. *
  236. ****************************************************************************
  237. */
  238. .section ".text.prot_to_real", "ax", @progbits
  239. .code32
  240. prot_to_real:
  241. /* Copy real-mode global descriptor table register to RM code segment */
  242. movl text16, %edi
  243. leal rm_gdtr(%edi), %edi
  244. movsw
  245. movsl
  246. /* Load real-mode interrupt descriptor table register */
  247. lidt (%esi)
  248. /* Add return address to data to be moved to RM stack */
  249. addl $4, %ecx
  250. /* Real-mode %ss:sp => %ebp:edx and virtual address => %edi */
  251. movzwl rm_ss, %ebp
  252. movzwl rm_sp, %edx
  253. subl %ecx, %edx
  254. movl %ebp, %eax
  255. shll $4, %eax
  256. leal (%eax,%edx), %edi
  257. subl virt_offset, %edi
  258. /* Move data from PM stack to RM stack */
  259. movl %esp, %esi
  260. rep movsb
  261. /* Record protected-mode %esp (after removal of data) */
  262. movl %esi, pm_esp
  263. /* Load real-mode segment limits */
  264. movw $REAL_DS, %ax
  265. movw %ax, %ds
  266. movw %ax, %es
  267. movw %ax, %fs
  268. movw %ax, %gs
  269. movw %ax, %ss
  270. ljmp $REAL_CS, $p2r_rmode
  271. .section ".text16.prot_to_real", "ax", @progbits
  272. .code16
  273. p2r_rmode:
  274. /* Load real-mode GDT */
  275. data32 lgdt %cs:rm_gdtr
  276. /* Switch to real mode */
  277. movl %cr0, %eax
  278. andb $0!CR0_PE, %al
  279. movl %eax, %cr0
  280. p2r_ljmp_rm_cs:
  281. ljmp $0, $1f
  282. 1:
  283. /* Set up real-mode data segments and stack pointer */
  284. movw %cs:rm_ds, %ax
  285. movw %ax, %ds
  286. movw %ax, %es
  287. movw %ax, %fs
  288. movw %ax, %gs
  289. movw %bp, %ss
  290. movl %edx, %esp
  291. /* Return to real-mode address */
  292. data32 ret
  293. /* Real-mode code and data segments. Assigned by the call to
  294. * init_librm. rm_cs doubles as the segment part of the jump
  295. * instruction used by prot_to_real. Both are located in
  296. * .text16 rather than .data16: rm_cs since it forms part of
  297. * the jump instruction within the code segment, and rm_ds
  298. * since real-mode code needs to be able to locate the data
  299. * segment with no other reference available.
  300. */
  301. .globl rm_cs
  302. .equ rm_cs, ( p2r_ljmp_rm_cs + 3 )
  303. .section ".text16.data.rm_ds", "aw", @progbits
  304. .globl rm_ds
  305. rm_ds: .word 0
  306. /* Real-mode global and interrupt descriptor table registers */
  307. .section ".text16.data.rm_gdtr", "aw", @progbits
  308. rm_gdtr:
  309. .word 0 /* Limit */
  310. .long 0 /* Base */
  311. /****************************************************************************
  312. * prot_call (real-mode near call, 16-bit real-mode near return address)
  313. *
  314. * Call a specific C function in the protected-mode code. The
  315. * prototype of the C function must be
  316. * void function ( struct i386_all_regs *ix86 );
  317. * ix86 will point to a struct containing the real-mode registers
  318. * at entry to prot_call.
  319. *
  320. * All registers will be preserved across prot_call(), unless the C
  321. * function explicitly overwrites values in ix86. Interrupt status
  322. * and GDT will also be preserved. Gate A20 will be enabled.
  323. *
  324. * Note that prot_call() does not rely on the real-mode stack
  325. * remaining intact in order to return, since everything relevant is
  326. * copied to the protected-mode stack for the duration of the call.
  327. * In particular, this means that a real-mode prefix can make a call
  328. * to main() which will return correctly even if the prefix's stack
  329. * gets vapourised during the Etherboot run. (The prefix cannot rely
  330. * on anything else on the stack being preserved, so should move any
  331. * critical data to registers before calling main()).
  332. *
  333. * Parameters:
  334. * function : virtual address of protected-mode function to call
  335. *
  336. * Example usage:
  337. * pushl $pxe_api_call
  338. * call prot_call
  339. * to call in to the C function
  340. * void pxe_api_call ( struct i386_all_regs *ix86 );
  341. ****************************************************************************
  342. */
  343. .struct 0
  344. PC_OFFSET_GDT: .space 6
  345. PC_OFFSET_IDT: .space 6
  346. PC_OFFSET_IX86: .space SIZEOF_I386_ALL_REGS
  347. PC_OFFSET_PADDING: .space 2 /* for alignment */
  348. PC_OFFSET_RETADDR: .space 2
  349. PC_OFFSET_FUNCTION: .space 4
  350. PC_OFFSET_END:
  351. .previous
  352. .section ".text16.prot_call", "ax", @progbits
  353. .code16
  354. .globl prot_call
  355. prot_call:
  356. /* Preserve registers, flags and GDT on external RM stack */
  357. pushfw /* padding */
  358. pushfl
  359. pushal
  360. pushw %gs
  361. pushw %fs
  362. pushw %es
  363. pushw %ds
  364. pushw %ss
  365. pushw %cs
  366. subw $PC_OFFSET_IX86, %sp
  367. movw %sp, %bp
  368. sidt PC_OFFSET_IDT(%bp)
  369. sgdt PC_OFFSET_GDT(%bp)
  370. /* For sanity's sake, clear the direction flag as soon as possible */
  371. cld
  372. /* Switch to protected mode and move register dump to PM stack */
  373. movl $PC_OFFSET_END, %ecx
  374. pushl $pc_pmode
  375. jmp real_to_prot
  376. .section ".text.prot_call", "ax", @progbits
  377. .code32
  378. pc_pmode:
  379. /* Call function */
  380. leal PC_OFFSET_IX86(%esp), %eax
  381. pushl %eax
  382. call *(PC_OFFSET_FUNCTION+4)(%esp)
  383. popl %eax /* discard */
  384. /* Switch to real mode and move register dump back to RM stack */
  385. movl $PC_OFFSET_END, %ecx
  386. movl %esp, %esi
  387. pushl $pc_rmode
  388. jmp prot_to_real
  389. .section ".text16.prot_call", "ax", @progbits
  390. .code16
  391. pc_rmode:
  392. /* Restore registers and flags and return */
  393. addw $( PC_OFFSET_IX86 + 4 /* also skip %cs and %ss */ ), %sp
  394. popw %ds
  395. popw %es
  396. popw %fs
  397. popw %gs
  398. popal
  399. /* popal skips %esp. We therefore want to do "movl -20(%sp),
  400. * %esp", but -20(%sp) is not a valid 80386 expression.
  401. * Fortunately, prot_to_real() zeroes the high word of %esp, so
  402. * we can just use -20(%esp) instead.
  403. */
  404. addr32 movl -20(%esp), %esp
  405. popfl
  406. popfw /* padding */
  407. ret $4
  408. /****************************************************************************
  409. * real_call (protected-mode near call, 32-bit virtual return address)
  410. *
  411. * Call a real-mode function from protected-mode code.
  412. *
  413. * The non-segment register values will be passed directly to the
  414. * real-mode code. The segment registers will be set as per
  415. * prot_to_real. The non-segment register values set by the real-mode
  416. * function will be passed back to the protected-mode caller. A
  417. * result of this is that this routine cannot be called directly from
  418. * C code, since it clobbers registers that the C ABI expects the
  419. * callee to preserve.
  420. *
  421. * librm.h defines a convenient macro REAL_CODE() for using real_call.
  422. * See librm.h and realmode.h for details and examples.
  423. *
  424. * Parameters:
  425. * (32-bit) near pointer to real-mode function to call
  426. *
  427. * Returns: none
  428. ****************************************************************************
  429. */
  430. .struct 0
  431. RC_OFFSET_REGS: .space SIZEOF_I386_REGS
  432. RC_OFFSET_REGS_END:
  433. RC_OFFSET_RETADDR: .space 4
  434. RC_OFFSET_FUNCTION: .space 4
  435. RC_OFFSET_END:
  436. .previous
  437. .section ".text.real_call", "ax", @progbits
  438. .code32
  439. .globl real_call
  440. real_call:
  441. /* Create register dump and function pointer copy on PM stack */
  442. pushal
  443. pushl RC_OFFSET_FUNCTION(%esp)
  444. /* Switch to real mode and move register dump to RM stack */
  445. movl $( RC_OFFSET_REGS_END + 4 /* function pointer copy */ ), %ecx
  446. pushl $rc_rmode
  447. movl $rm_default_gdtr_idtr, %esi
  448. jmp prot_to_real
  449. .section ".text16.real_call", "ax", @progbits
  450. .code16
  451. rc_rmode:
  452. /* Call real-mode function */
  453. popl rc_function
  454. popal
  455. call *rc_function
  456. pushal
  457. /* For sanity's sake, clear the direction flag as soon as possible */
  458. cld
  459. /* Switch to protected mode and move register dump back to PM stack */
  460. movl $RC_OFFSET_REGS_END, %ecx
  461. pushl $rc_pmode
  462. jmp real_to_prot
  463. .section ".text.real_call", "ax", @progbits
  464. .code32
  465. rc_pmode:
  466. /* Restore registers and return */
  467. popal
  468. ret $4
  469. /* Function vector, used because "call xx(%sp)" is not a valid
  470. * 16-bit expression.
  471. */
  472. .section ".bss16.rc_function", "aw", @nobits
  473. rc_function: .word 0, 0
  474. /* Default real-mode global and interrupt descriptor table registers */
  475. .section ".data.rm_default_gdtr_idtr", "aw", @progbits
  476. rm_default_gdtr_idtr:
  477. .word 0 /* Global descriptor table limit */
  478. .long 0 /* Global descriptor table base */
  479. .word 0x03ff /* Interrupt descriptor table limit */
  480. .long 0 /* Interrupt descriptor table base */
  481. /****************************************************************************
  482. * flatten_real_mode (real-mode near call)
  483. *
  484. * Switch to flat real mode
  485. *
  486. ****************************************************************************
  487. */
  488. .section ".text16.flatten_real_mode", "ax", @progbits
  489. .code16
  490. .globl flatten_real_mode
  491. flatten_real_mode:
  492. /* Modify GDT to use flat real mode */
  493. movb $0x8f, real_cs + 6
  494. movb $0x8f, real_ds + 6
  495. /* Call dummy protected-mode function */
  496. virtcall flatten_dummy
  497. /* Restore GDT */
  498. movb $0x00, real_cs + 6
  499. movb $0x00, real_ds + 6
  500. /* Return */
  501. ret
  502. .section ".text.flatten_dummy", "ax", @progbits
  503. .code32
  504. flatten_dummy:
  505. ret
  506. /****************************************************************************
  507. * Interrupt wrapper
  508. *
  509. * Used by the protected-mode interrupt vectors to call the
  510. * interrupt() function.
  511. *
  512. * May be entered with either physical or virtual stack segment.
  513. ****************************************************************************
  514. */
  515. .globl interrupt_wrapper
  516. interrupt_wrapper:
  517. /* Preserve segment registers and original %esp */
  518. pushl %ds
  519. pushl %es
  520. pushl %fs
  521. pushl %gs
  522. pushl %ss
  523. pushl %esp
  524. /* Switch to virtual addressing */
  525. call _intr_to_virt
  526. /* Expand IRQ number to whole %eax register */
  527. movzbl %al, %eax
  528. /* Call interrupt handler */
  529. call interrupt
  530. /* Restore original stack and segment registers */
  531. lss (%esp), %esp
  532. popl %ss
  533. popl %gs
  534. popl %fs
  535. popl %es
  536. popl %ds
  537. /* Restore registers and return */
  538. popal
  539. iret
  540. /****************************************************************************
  541. * Stored real-mode and protected-mode stack pointers
  542. *
  543. * The real-mode stack pointer is stored here whenever real_to_prot
  544. * is called and restored whenever prot_to_real is called. The
  545. * converse happens for the protected-mode stack pointer.
  546. *
  547. * Despite initial appearances this scheme is, in fact re-entrant,
  548. * because program flow dictates that we always return via the point
  549. * we left by. For example:
  550. * PXE API call entry
  551. * 1 real => prot
  552. * ...
  553. * Print a text string
  554. * ...
  555. * 2 prot => real
  556. * INT 10
  557. * 3 real => prot
  558. * ...
  559. * ...
  560. * 4 prot => real
  561. * PXE API call exit
  562. *
  563. * At point 1, the RM mode stack value, say RPXE, is stored in
  564. * rm_ss,sp. We want this value to still be present in rm_ss,sp when
  565. * we reach point 4.
  566. *
  567. * At point 2, the RM stack value is restored from RPXE. At point 3,
  568. * the RM stack value is again stored in rm_ss,sp. This *does*
  569. * overwrite the RPXE that we have stored there, but it's the same
  570. * value, since the code between points 2 and 3 has managed to return
  571. * to us.
  572. ****************************************************************************
  573. */
  574. .section ".bss.rm_sp", "aw", @nobits
  575. .globl rm_sp
  576. rm_sp: .word 0
  577. .section ".bss.rm_ss", "aw", @nobits
  578. .globl rm_ss
  579. rm_ss: .word 0
  580. .section ".data.pm_esp", "aw", @progbits
  581. pm_esp: .long _estack
  582. /****************************************************************************
  583. * Virtual address offsets
  584. *
  585. * These are used by the protected-mode code to map between virtual
  586. * and physical addresses, and to access variables in the .text16 or
  587. * .data16 segments.
  588. ****************************************************************************
  589. */
  590. /* Internal copies, created by init_librm (which runs in real mode) */
  591. .section ".bss16.rm_virt_offset", "aw", @nobits
  592. rm_virt_offset: .long 0
  593. rm_text16: .long 0
  594. rm_data16: .long 0
  595. /* Externally-visible copies, created by real_to_prot */
  596. .section ".bss.virt_offset", "aw", @nobits
  597. .globl virt_offset
  598. virt_offset: .long 0
  599. .globl text16
  600. text16: .long 0
  601. .globl data16
  602. data16: .long 0