MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / iret

Method iret

source/emulation/cpu/common/cpu.cpp:664–829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

662}
663
664void CPU::iret(U32 big, U32 oldeip) {
665 CPU* cpu = this;
666
667 if (this->flags & VM) {
668 if ((this->flags & IOPL)!=IOPL) {
669 this->prepareException(EXCEPTION_GP, 0);
670 return;
671 } else {
672 if (big) {
673 U32 new_eip = this->peek32(0);
674 U32 new_cs = this->peek32(1);
675 U32 new_flags = this->peek32(2);
676
677 ESP = (ESP & this->stackNotMask) | ((ESP + 12) & this->stackMask);
678
679 this->eip.u32 = new_eip;
680 this->setSegment(CS, new_cs & 0xFFFF);
681
682 /* IOPL can not be modified in v86 mode by IRET */
683 this->setFlags(new_flags, FMASK_NORMAL | NT);
684 } else {
685 U32 new_eip = this->peek16(0);
686 U32 new_cs = this->peek16(1);
687 U32 new_flags = this->peek16(2);
688
689 ESP = (ESP & this->stackNotMask) | ((ESP + 6) & this->stackMask);
690
691 cpu->eip.u32 = new_eip;
692 this->setSegment(CS, new_cs);
693 /* IOPL can not be modified in v86 mode by IRET */
694 cpu->setFlags(new_flags, FMASK_NORMAL | NT);
695 }
696 this->setIsBig(0);
697 this->lazyFlagType = FLAGS_NONE;
698 return;
699 }
700 }
701 /* Check if this is task IRET */
702 if (this->flags & NT) {
703 kpanic("cpu tasks not implemented");
704 return;
705 } else {
706 U32 n_cs_sel = 0;
707 U32 n_flags = 0;
708 U32 n_eip = 0;
709
710 if (big) {
711 n_eip = this->peek32(0);
712 n_cs_sel = this->peek32(1) & 0xffff;
713 n_flags = this->peek32(2);
714
715 if ((n_flags & VM) && (this->cpl==0)) {
716 // commit point
717 ESP = (ESP & this->stackNotMask) | ((ESP + 12) & this->stackMask);
718 this->eip.u32 = n_eip & 0xffff;
719 U32 n_esp=this->pop32();
720 U32 n_ss=this->pop32() & 0xffff;
721 U32 n_es=this->pop32() & 0xffff;

Callers 3

common_iretFunction · 0.80
normal_iretFunction · 0.80
normal_iret32Function · 0.80

Calls 12

prepareExceptionMethod · 0.95
peek32Method · 0.95
setSegmentMethod · 0.95
setFlagsMethod · 0.95
peek16Method · 0.95
setIsBigMethod · 0.95
pop32Method · 0.95
setSegMethod · 0.95
kpanicFunction · 0.85
CPU_CHECK_CONDFunction · 0.85
isLdtEmptyMethod · 0.80
getLDTMethod · 0.45

Tested by

no test coverage detected