Questions tagged [protected-mode]

x86 protected mode allows system software to support virtual memory, paging and preemptive multi-tasking.

x86 protected mode allows system software to support virtual memory, paging and preemptive multi-tasking.

  • Protected mode was first added to the x86 architecture in 1982, with the release of Intel's 80286 processor, and later extended with the release of the 80386 processor in 1985.
  • To maintain backward compatibility, x86 processors begins executing instructions in real mode.

To enter protected mode:

  • The Global Descriptor Table (GDT) must first be created with a minimum of three entries: a null descriptor, a code segment descriptor and data segment descriptor.
  • In an IBM-compatible machine, the A20 line (21st address line) also must be enabled to allow the use of all the address lines so that the CPU can access beyond 1 megabyte of memory.
  • Then the PE bit must be set in the CR0 register and a far jump must be made to clear the prefetch input queue:
; set PE bit
mov eax, cr0
or eax, 1
mov cr0, eax

; far jump (cs = selector of code segment)
jmp cs:@pm

@pm:
; Now we are in PM.
214 questions
0
votes
1 answer

Interrupt descriptor table in multiprocessor system

I read that in multiprocessor system each processor has its own copy of interrupt descriptor table (IDT) and they use one copy of global descriptor table (GDT). Why processors can't use one copy of IDT?
0
votes
1 answer

Any attempt to put a string to the screen in Protected Mode causes reboot

I have just recently gone into Protected Mode when developing an OS from scratch. I have managed to get into C and make functions to print characters to the screen (thanks Michael Petch for helping me reach this stage). Anyway, whenever I try to…
0
votes
1 answer

Needs to run test in selenium with protected mode settings

while using selenium is it possible to run script in selenium if some options(Protected mode settings..) are checked and some are unchecked. Or is there any alternate to break Protected mode security to make runs work in IE browser using…
Jimmy
  • 35
  • 2
  • 9
0
votes
0 answers

Switching to (un)real mode, reading disk and switching back to protected mode

My question is quite a bit theoretical, but I want to implement disk r/w to my Operating system, while I know how to do it in protected mode, it would take too long to implement ATAPI+ATA+FDC drivers (to make my OS boot on any device). I took two…
Kamila Szewczyk
  • 1,874
  • 1
  • 16
  • 33
0
votes
0 answers

How do I write and then execute kernel code from a file in protected mode?

When using rep insw in 32-bit protected mode to load my kernel from disk to memory, how do I properly write the data to memory, and then execute it? If I understand correctly, the data segment can be written to, but not executed, and the code…
Wyllow Wulf
  • 410
  • 4
  • 23
0
votes
1 answer

How to put a pixel on the screen?

I'm looking for information how to insert a pixel into the screen in my own operating system. I care about the resolution of 1920x1080, 16K colors and to do it without bios interruptions. Ideally, the resolution and number of colors will depend on…
0
votes
1 answer

NASM drawing in protected mode

I seen that using interrupts it is only possible to draw on low resolution. Let's say that I am making simple OS that would display on any resolution, like 4k, 1920x1080. I have Intel x64 processor with Intel HD graphics and Nvidia card. I am on…
0
votes
0 answers

Linear addressing and the GDT

I struggle to setup the GDT and to switch to protected mode. Mostly because i didn't understand linear addressing well enough. Here is my kernel code (kernel.asm): jmp main %include "gdt.inc" main: call InstallGDT cli mov eax,cr0 or eax,1 mov…
albert
  • 113
  • 1
  • 12
0
votes
0 answers

Creating non-overlapping segments in Global Descriptor Table

In this bootloader, I'm trying to set up separate global descriptor table entries for kernel code and user code (albeit with some simplifications, see the comments). Creating disjoint segments is causing a triple fault, even though the segments have…
Vale132
  • 147
  • 8
0
votes
1 answer

why real mode applications cannot be run in a protected mode?

I was studying this real to protected mode transition. I had a doubt whether real to protected mode can happen without loading ldt and idt but by loading gdt. With that on one side, a second doubt arised such that why real mode programs cannot be…
Panther Coder
  • 1,058
  • 1
  • 16
  • 43
0
votes
0 answers

80386 Paging and Segmenation

I'm trying to understand a few things regarding paging and segmentation... Firstly, In order to implement protected mode within, Is segmentation required? could it be implemented paging? from what I understood every code segment has some…
0
votes
1 answer

How does the user to kernel mode switch occur before the Interrupt Gate descriptor is accessed?

I am currently reading "Understanding the Linux Kernel". I am studying the Interrupts and Exceptions chapter. I found that when setting up IDT we can use five kinds of gate descriptors in Linux terminology Task Gate (DPL: 0) Interrupt gate (DPL:…
nishad kamdar
  • 67
  • 2
  • 11
0
votes
1 answer

How different segments are set in 32bit protected mode?

As I know all the segment registers or selectors are set to point to the same starting address of the 4gb segment in 32 bit protected mode flat model. So how the stack segment functionality is implemented which is it starts at one of the top address…
Kaustav
  • 741
  • 1
  • 9
  • 18
0
votes
0 answers

Why this code is crashing when call procedure in loop?

I tried to write own simple bootloader, I had this code: .code16 # Generate 16 bit code .globl set_protected_mode .globl set_real_mode __init: call set_protected_mode call set_real_mode jmp __init # jmp init # Jump to init function in…
krystian71115
  • 1,927
  • 17
  • 36
0
votes
1 answer

Bochs: assembly far jump got lost in bogus memory area (invalid opcode error)

I started to develop a small toy operating system in (NASM) assembly, just for my entertainment. I've written a bootloader that loads the first (and only one) file from a FAT12 file system called "kernel.sys" into the memory at offset 0x7E00. In…
Kerberos
  • 67
  • 7