MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm86_initialize_nopae

Function vm86_initialize_nopae

freebsd/i386/i386/vm86.c:528–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526}
527
528static void
529vm86_initialize_nopae(void)
530{
531 int i;
532 u_int *addr;
533 struct vm86_layout_nopae *vml;
534 struct pcb *pcb;
535 struct pcb_ext *ext;
536 struct soft_segment_descriptor ssd = {
537 0, /* segment base address (overwritten) */
538 0, /* length (overwritten) */
539 SDT_SYS386TSS, /* segment type */
540 0, /* priority level */
541 1, /* descriptor present */
542 0, 0,
543 0, /* default 16 size */
544 0 /* granularity */
545 };
546
547 vml = (struct vm86_layout_nopae *)vm86paddr;
548 pcb = &vml->vml_pcb;
549 ext = &vml->vml_ext;
550
551 mtx_init(&vm86_lock, "vm86 lock", NULL, MTX_DEF);
552
553 bzero(pcb, sizeof(struct pcb));
554 pcb->new_ptd = vm86pa | PG_V | PG_RW | PG_U;
555 pcb->vm86_frame = vm86paddr - sizeof(struct vm86frame);
556 pcb->pgtable_va = vm86paddr;
557 pcb->pcb_flags = PCB_VM86CALL;
558 pcb->pcb_ext = ext;
559
560 bzero(ext, sizeof(struct pcb_ext));
561 ext->ext_tss.tss_esp0 = vm86paddr;
562 ext->ext_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
563 ext->ext_tss.tss_ioopt =
564 ((u_int)vml->vml_iomap - (u_int)&ext->ext_tss) << 16;
565 ext->ext_iomap = vml->vml_iomap;
566 ext->ext_vm86.vm86_intmap = vml->vml_intmap;
567
568 if (cpu_feature & CPUID_VME)
569 ext->ext_vm86.vm86_has_vme = (rcr4() & CR4_VME ? 1 : 0);
570
571 addr = (u_int *)ext->ext_vm86.vm86_intmap;
572 for (i = 0; i < (INTMAP_SIZE + IOMAP_SIZE) / sizeof(u_int); i++)
573 *addr++ = 0;
574 vml->vml_iomap_trailer = 0xff;
575
576 ssd.ssd_base = (u_int)&ext->ext_tss;
577 ssd.ssd_limit = TSS_SIZE - 1;
578 ssdtosd(&ssd, &ext->ext_tssd);
579
580 vm86pcb = pcb;
581
582#if 0
583 /*
584 * use whatever is leftover of the vm86 page layout as a
585 * message buffer so we can capture early output.

Callers 1

vm86_initializeFunction · 0.85

Calls 5

mtx_initFunction · 0.85
bzeroFunction · 0.85
ssdtosdFunction · 0.85
msgbufinitFunction · 0.85
rcr4Function · 0.50

Tested by

no test coverage detected