flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Another Pmode Problem... Please Help!

Author
Thread Post new topic Reply to topic
MialyGK



Joined: 19 May 2005
Posts: 4
Location: Varna, Bulgaria
MialyGK 23 Aug 2005, 18:14
Hello!
I have one problem Razz ! When My OS switch to Protected mode, My PC just restart !!!
Where is the "dirty" code ? Please Help me!
The Assembler Compiler, who i use is NASM, but soon - FASM!

Kernel Code (here is "pmode" code...):
Code:
[CPU 386]
[Bits 16]
[org 0x10000]
     jmp       _start

gdt:
db   0,0,0,0,0,0,0,0

db   0xFF,0xFF ;# Limit FFFF
db   0x00,0x00 ;# Base Low
db   0x09,0x9A ;# Base med,Type Code
db   0xCF,0x00 ;# Access, base high


db   0xFF,0xFF ;# Limit FFFF
db   0x00,0x00 ;# Base Low
db   0x09,0x92 ;# Base med,Type Data
db   0xCF,0x00 ;# Access, base high

set_gdt:
db   0x20
dd   gdt

Text db 'Switching to Protect Mode... [ok]',0 ;# Ha-ha-ha Razz
cursor dd 0
_start:

     cli
     mov       ax,cs
     mov       ds,ax
     mov       es,ax
     mov       ss,ax
     mov       sp,_start

;# Stop the Floppy Motor for now;-)
     mov       dx,0x3f2
     xor       ax,ax
     out       dx,al

;# Stop Interrupts
     mov       al,0xFF
     out       0x21,al
     out       0xA1,al
     mov       dx,0x70
     in        al,dx
     or        al,0x80
     out       dx,al
;# Enable A20 Gate
     in        al,0x92
     or        al,2
     out       0x92,al
;# Load LGDT and switch to Protected Mode
     lgdt      [set_gdt]
     mov       ecx,cr0
     or        cl,1
     mov       cr0,ecx

     jmp       dword (0x08):_protect
_protect:
[BITS 32]

     mov       ax,10
     mov       ds,ax
     mov       es,ax
     mov       fs,ax
     mov       ss,ax

     mov       esi,Text
     call      kputs

quit:
     
     halt
     jmp       short $

kputs:
     pusha
.loop:  
     lodsb 
     test al, al
     jz quit

     mov ecx, [cursor]
     mov [0xB8000+ecx*2], al
     inc dword [cursor]
     jmp short .loop
    

And Boot Code (If this is the BAD code):
Code:

[ORG 0x7c00]
[BITS 16]
[CPU 386]

     jmp       _main

;#########################
;# Structure of boot:

Signature      db 'lofs'
Fs_Version     db 0,0,0,1
Loading        db 'Loading',10,13,0
Need386        db 13,10,'386+ CPU required.',0
ErrorMsg       db 13,10,'Error: ',0
HexDig         db '0123456789ABCDEF'
Drive          db 0x00
MaxSectors     db 0x00
MaxHeads       db 0x00

;#########################
;# Function: _print
;# In: DS:SI := ASCIIz string
;# Out: <none>
;# Require: push AX,BX

_print:
     lodsb                             ;# load DS:SI into AL
     or        al,al                   ;# if (AL==0) ...
     jz        .1                      ;#  ... goto 1
     mov       ah,0x0E                 ;# func. #0E (BIOS)
     mov       bx,0100                 ;# text page
     int       0x10                    ;# BIOS interrupt
     jmp       _print                  ;# Next Letter
.1:  ret                               ;# return
_end_print:
  
;#########################
;# Function: _puthex
;# In: CL:=Code
;# Out: <none>
;# Require: BX,AX

_puthex:
     push      cx                      ;# Save original Code (xxxxyyyy)
     shr       cl,4                    ;# xxxxyyyy >> 4 = 0000xxxx
     and       cx,0x000F               ;# 000000000000xxxx
     call      .1                      ;# print hex. number
     pop       cx                      ;# Load Code
     and       cx,0x000F               ;# 000000000000yyyy
     call      .1                      ;# print hex. number
     ret                               ;# return
.1:  mov       bx,cx                   ;# bx = cx
     mov       al,[HexDig+bx]          ;# bx+HexDig = ASCII Number
     mov       ah,0x0E                 ;# BIOS 0x0E (print char)
     xor       bx,bx                   ;# page 0, attribute 0
     int       0x10                    ;# and print
     ret                               ;# return

;#########################
;# Function: _inc_CHS
;# In: cx,dh = CHS
;# Out: cx,dh = CHS

_inc_CHS:
     mov       al,cl                   ;# save sector and high cylinder
     and       cl,0x3F                 ;# cl = 00ssssss s=sector
     and       al,0xC0                 ;# al = cc000000 c=cylinder
     inc       cl                      ;# cl++;
     cmp       cl,[MaxSectors]         ;# if cl<MaxSector
     jna       .1                      ;# jump to .1
     mov       cl,1                    ;# else cl = sector 1
     inc       dh                      ;# and dh(head)++
     cmp       dh,[MaxHeads]           ;# if dh<MaxHeads
     jna       .1                      ;# jump to .1
     xor       dh,dh                   ;# else dh=0
     inc       ch                      ;# ch(low Cylinder)++
     jno       .1                      ;# jump if no overflow (else ch=0)
     add       al,0x40                 ;# else al+= c1000000 c=cylinder
.1:  or        al,cl                   ;# and 00ssssss | cc000000 = ccssssss (new CHS)
     ret                               ;# and return
      
;#########################
;# Function: _readsector
;# In: si:= number of sectors
;#   cx, dh = CHS
;# Out: es:bx:=Load Data from Diskette

_readsector:      
     jmp       .2                      ;# readsector normal
.1:  xor       ax,ax                   ;# reset drive
     mov       dl,[Drive]              ;# dl=drive number (0=A, 1=B)
     int       0x13                    ;# BIOS execute
     jc         .3                     ;# if(CF == 1) erorr()
.2:  mov       bx,di                   ;# ES:BX = Address to write
     mov       ax,0x0201               ;# read one sector
     int       0x13                    ;# BIOS interrupt
     jc        .1                      ;# if CF == 1 error()
     mov       ax,0x0E2E               ;# print '.'
     xor       bx,bx                   ;# clear attributes
     int       0x10                    ;# and print
     call      _inc_CHS                ;# for next -> CHS++
     add       di,512                  ;# di+=512 next sector
     dec       si                      ;# number of sectors
     jnz       .2                      ;# if sectors != 0 jump .2
     ret                               ;# return
.3:  jmp       _error                  ;# go to error
_end_readsector:

;#########################
;# Function: _error
;# In: ax:=error code
;# Out: <none>
;# Require: 'ErrorMsg' string

_error:
     push      ax                      ;# save ax
     mov       si,ErrorMsg             ;# print
     call      _print                  ;# 'Error' msg
     pop       ax                      ;# load ax
     push      ax                      ;# save ax
     mov       cl,ah                   ;# cl=high byte
     call      _puthex                 ;# from Code
     pop       ax                      ;# load ax
     mov       cl,al                   ;# cl=low byte
     call      _puthex                 ;# from Code
     xor       ax,ax                   ;# wait for
     int       0x16                    ;#  ... key press
     jmp       0xFFFF:0x0000           ;# Restart in real mode
     hlt                               ;# halt if have error with the restart

;#########################
;# Function: _detectcpu
;# In: <none>
;# Out: <none>
;# Require: Global variable
;#   Need386

_detectcpu:
;# detect for 8086/88 (flags 12-15 will be set)
     pushf                             ;# Save flags to stack
     xor       ah,ah                   ;# AH:=0
     push      ax                      ;# Save AX to stack
     popf                              ;# load word from stack
     pushf                             ;# Save flags to stack
     pop       ax                      ;# and load to AX
     and       ah,0xf0                 ;# check if bits 12-15 are set
     cmp       ah,0xf0                 ;# if AH = 11110000
     je        .1                      ;# jump if yes (i.e. is 8086/8Cool

;# detect for 286 (flags 12-15 not will set)
     mov       ah,0xf0                 ;# AH:=11110000
     push      ax                      ;# save ax into stack
     popf                              ;# and load into flags
     pushf                             ;# save flags into flags
     pop       ax                      ;# load word into stack
     and       ah,0xf0                 ;# AH & 11110000 = 00000000
     jz        .1                      ;# jump if zero (i.e. is 286)
     popf                              ;# load word into flags
     ret                               ;# else CPU is 386+
.1:  mov       si,Need386              ;# Print text for Not Found CPU 80386
     call      _print                  ;#
     jmp       _error                  ;# and jump to _error 


;#########################
;# main() function:
_main:
     mov       ax,cs                   ;# AX:=Loading boot
     mov       ds,ax                   ;# DS:=AX
     cli                               ;# clear interrupt flag (protect SS)
     mov       ax,0x8000               ;# AX:=stack
     mov       ss,ax                   ;# SS:=80000
     mov       sp,0xFFFF               ;# SP:=FFFF  => stack:=8FFFF
     sti                               ;# set interrupt flag
     mov       es,ax                   ;# AX:=buffer of kernel sectors
     mov       [Drive],dl              ;# Save Currect Drive
     mov       ah,0x08                 ;# Get Info
     int       0x13                    ;# From BIOS
     jc        _error                  ;# if (CF==1) goto error
     and       cl,0x3F                 ;# Clear high Cylinder
     mov       [MaxSectors],cl         ;# and save
     mov       [MaxHeads],dh           ;# Heads save
     mov       si,Loading              ;# print
     call      _print                  ;#  on screen
     call      _detectcpu              ;# Detecting CPU for 386+
_loading:
     mov       cx,0x0002               ;# CHS = 0,0,2 (skip boot sector)
     xor       dh,dh                   ;# Head = 0
     mov       dl,[Drive]              ;# DL:= Drive Number (0-A, 1-B)
     mov       si,0x40                 ;# 40H:=64
     mov       ax,0x1000               ;# destination
     mov       es,ax                   ;# segment - es:bx
     xor       bx,bx                   ;# bx must be 0
     xor       di,di                   ;# di->bx
     call      _readsector             ;# read!
     jmp       0x1000:0x0000           ;# jump to kernel! 
     mov       si,ErrorMsg
     call      _print
     hlt                               ;# System halt
     jmp       $                       ;# Forever Cycle
     times     0x1fe-($-$$) db 0x90    ;# all "unused" bytes - NOP 
     dw        0xAA55                  ;# signature for correct boot

    

P.S. Sorry for my "primitive" English! I am Bulgarian... Embarassed
Post 23 Aug 2005, 18:14
View user's profile Send private message Visit poster's website Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 23 Aug 2005, 18:19
Don't you use cli to stop interrupts?

_________________
This calls for... Ultra CRUNCHY Man!
Ta da!! *crunch*
Post 23 Aug 2005, 18:19
View user's profile Send private message Reply with quote
MialyGK



Joined: 19 May 2005
Posts: 4
Location: Varna, Bulgaria
MialyGK 23 Aug 2005, 18:32
UCM wrote:
Don't you use cli to stop interrupts?


Wow, too Fast post...Shocked

I use CLI in boot and the kernel, but the problem still over there...
Post 23 Aug 2005, 18:32
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 23 Aug 2005, 19:03
Reposition _protect: under bits 32, not that that is the problem, but that glares at me. The reason is you're jumping to 32-bits and when the label _protect: is in 16-bits it just doesn't seem right.

Your GDTR doesn't look right either:

Code:
GDTR:   dw GDTEnd - GDT - 1
        dd GDT
    


In yours it is only 5 bytes, and it should be 6. The first word should be the size in bytes. So you should be able to change it to:

Code:
set_gdt: 
; db   0x20 Commented out this BAD code. Wink
dw   set_gdt - gdt - 1
dd   gdt
    


I hope that gets you squared away!
Post 23 Aug 2005, 19:03
View user's profile Send private message Reply with quote
Artlav



Joined: 23 Dec 2004
Posts: 188
Location: Moscow, Russia
Artlav 23 Aug 2005, 19:07
Try removing [org 0x10000] from under the [BITS 16] and putting it under the [BITS 32].
And GDT looks suspicious...
Post 23 Aug 2005, 19:07
View user's profile Send private message Visit poster's website Reply with quote
MialyGK



Joined: 19 May 2005
Posts: 4
Location: Varna, Bulgaria
MialyGK 24 Aug 2005, 05:17
smiddy wrote:
Reposition _protect: under bits 32, not that that is the problem, but that glares at me. The reason is you're jumping to 32-bits and when the label _protect: is in 16-bits it just doesn't seem right.
.......

Artlav wrote:
Try removing [org 0x10000] from under the [BITS 16] and putting it under the [BITS 32].
And GDT looks suspicious...


I try but don't work Sad Help
Post 24 Aug 2005, 05:17
View user's profile Send private message Visit poster's website Reply with quote
Artlav



Joined: 23 Dec 2004
Posts: 188
Location: Moscow, Russia
Artlav 24 Aug 2005, 06:36
Ok, runned this through a debugger.

1. Right GDT:
db 0xFF,0xFF ;# Limit FFFF
db 0x00,0x00 ;# Base Low
db 0x00,0x9A ;# Base med,Type Code
db 0xCF,0x00 ;# Access, base high


db 0xFF,0xFF ;# Limit FFFF
db 0x00,0x00 ;# Base Low
db 0x00,0x92 ;# Base med,Type Data
db 0xCF,0x00 ;# Access, base high

set_gdt:
dw set_gdt-gdt-1
dd gdt

The problem here is Base med byte, which was 0x09 instead of 0, which gave 0x00090000 base address insted of 0x00000000.
And set_gdt,
db 0x20 <-- The size is a word, not byte
dd gdt

2. [org 0x10000] Should be under [Bits 32] to link the latter code for flat 0x10000.

3. Typo - line 63: mov ax,10
Selector is 0x10 instead of 10.
Post 24 Aug 2005, 06:36
View user's profile Send private message Visit poster's website Reply with quote
MialyGK



Joined: 19 May 2005
Posts: 4
Location: Varna, Bulgaria
MialyGK 24 Aug 2005, 10:38
Thanks all!
This is my modifications of:

boot code (last lines):
Code:
ORG 0x7c00
BITS 16
CPU 386

     jmp       _main

;#########################
;# Structure of boot:

Signature      db 'lofs'
Fs_Version     db 0,0,0,1
Loading        db 'Loading',10,13,0
Need386        db 13,10,'386+ CPU required.',0
ErrorMsg       db 13,10,'Error: ',0
HexDig         db '0123456789ABCDEF'
Drive          db 0x00
MaxSectors     db 0x00
MaxHeads       db 0x00

;#########################
;# Function: _print
;# In: DS:SI := ASCIIz string
;# Out: <none>
;# Require: push AX,BX

_print:
     lodsb                             ;# load DS:SI into AL
     or        al,al                   ;# if (AL==0) ...
     jz        .1                      ;#  ... goto 1
     mov       ah,0x0E                 ;# func. #0E (BIOS)
     mov       bx,0100                 ;# text page
     int       0x10                    ;# BIOS interrupt
     jmp       _print                  ;# Next Letter
.1:  ret                               ;# return
_end_print:
  
;#########################
;# Function: _puthex
;# In: CL:=Code
;# Out: <none>
;# Require: BX,AX

_puthex:
     push      cx                      ;# Save original Code (xxxxyyyy)
     shr       cl,4                    ;# xxxxyyyy >> 4 = 0000xxxx
     and       cx,0x000F               ;# 000000000000xxxx
     call      .1                      ;# print hex. number
     pop       cx                      ;# Load Code
     and       cx,0x000F               ;# 000000000000yyyy
     call      .1                      ;# print hex. number
     ret                               ;# return
.1:  mov       bx,cx                   ;# bx = cx
     mov       al,[HexDig+bx]          ;# bx+HexDig = ASCII Number
     mov       ah,0x0E                 ;# BIOS 0x0E (print char)
     xor       bx,bx                   ;# page 0, attribute 0
     int       0x10                    ;# and print
     ret                               ;# return

;#########################
;# Function: _inc_CHS
;# In: cx,dh = CHS
;# Out: cx,dh = CHS

_inc_CHS:
     mov       al,cl                   ;# save sector and high cylinder
     and       cl,0x3F                 ;# cl = 00ssssss s=sector
     and       al,0xC0                 ;# al = cc000000 c=cylinder
     inc       cl                      ;# cl++;
     cmp       cl,[MaxSectors]         ;# if cl<MaxSector
     jna       .1                      ;# jump to .1
     mov       cl,1                    ;# else cl = sector 1
     inc       dh                      ;# and dh(head)++
     cmp       dh,[MaxHeads]           ;# if dh<MaxHeads
     jna       .1                      ;# jump to .1
     xor       dh,dh                   ;# else dh=0
     inc       ch                      ;# ch(low Cylinder)++
     jno       .1                      ;# jump if no overflow (else ch=0)
     add       al,0x40                 ;# else al+= c1000000 c=cylinder
.1:  or        al,cl                   ;# and 00ssssss | cc000000 = ccssssss (new CHS)
     ret                               ;# and return
      
;#########################
;# Function: _readsector
;# In: si:= number of sectors
;#   cx, dh = CHS
;# Out: es:bx:=Load Data from Diskette

_readsector:      
     jmp       .2                      ;# readsector normal
.1:  xor       ax,ax                   ;# reset drive
     mov       dl,[Drive]              ;# dl=drive number (0=A, 1=B)
     int       0x13                    ;# BIOS execute
     jc         .3                     ;# if(CF == 1) erorr()
.2:  mov       bx,di                   ;# ES:BX = Address to write
     mov       ax,0x0201               ;# read one sector
     int       0x13                    ;# BIOS interrupt
     jc        .1                      ;# if CF == 1 error()
     mov       ax,0x0E2E               ;# print '.'
     xor       bx,bx                   ;# clear attributes
     int       0x10                    ;# and print
     call      _inc_CHS                ;# for next -> CHS++
     add       di,512                  ;# di+=512 next sector
     dec       si                      ;# number of sectors
     jnz       .2                      ;# if sectors != 0 jump .2
     ret                               ;# return
.3:  jmp       _error                  ;# go to error
_end_readsector:

;#########################
;# Function: _error
;# In: ax:=error code
;# Out: <none>
;# Require: 'ErrorMsg' string

_error:
     push      ax                      ;# save ax
     mov       si,ErrorMsg             ;# print
     call      _print                  ;# 'Error' msg
     pop       ax                      ;# load ax
     push      ax                      ;# save ax
     mov       cl,ah                   ;# cl=high byte
     call      _puthex                 ;# from Code
     pop       ax                      ;# load ax
     mov       cl,al                   ;# cl=low byte
     call      _puthex                 ;# from Code
     xor       ax,ax                   ;# wait for
     int       0x16                    ;#  ... key press
     jmp       0xFFFF:0x0000           ;# Restart in real mode
     hlt                               ;# halt if have error with the restart

;#########################
;# Function: _detectcpu
;# In: <none>
;# Out: <none>
;# Require: Global variable
;#   Need386

_detectcpu:
;# detect for 8086/88 (flags 12-15 will be set)
     pushf                             ;# Save flags to stack
     xor       ah,ah                   ;# AH:=0
     push      ax                      ;# Save AX to stack
     popf                              ;# load word from stack
     pushf                             ;# Save flags to stack
     pop       ax                      ;# and load to AX
     and       ah,0xf0                 ;# check if bits 12-15 are set
     cmp       ah,0xf0                 ;# if AH = 11110000
     je        .1                      ;# jump if yes (i.e. is 8086/8Cool

;# detect for 286 (flags 12-15 not will set)
     mov       ah,0xf0                 ;# AH:=11110000
     push      ax                      ;# save ax into stack
     popf                              ;# and load into flags
     pushf                             ;# save flags into flags
     pop       ax                      ;# load word into stack
     and       ah,0xf0                 ;# AH & 11110000 = 00000000
     jz        .1                      ;# jump if zero (i.e. is 286)
     popf                              ;# load word into flags
     ret                               ;# else CPU is 386+
.1:  mov       si,Need386              ;# Print text for Not Found CPU 80386
     call      _print                  ;#
     jmp       _error                  ;# and jump to _error 


;#########################
;# main() function:
_main:
     mov       ax,cs                   ;# AX:=Loading boot
     mov       ds,ax                   ;# DS:=AX
     cli                               ;# clear interrupt flag (protect SS)
     mov       ax,0x8000               ;# AX:=stack
     mov       ss,ax                   ;# SS:=80000
     mov       sp,0xFFFF               ;# SP:=FFFF  => stack:=8FFFF
     sti                               ;# set interrupt flag
     mov       es,ax                   ;# AX:=buffer of kernel sectors
     mov       [Drive],dl              ;# Save Currect Drive
     mov       ah,0x08                 ;# Get Info
     int       0x13                    ;# From BIOS
     jc        _error                  ;# if (CF==1) goto error
     and       cl,0x3F                 ;# Clear high Cylinder
     mov       [MaxSectors],cl         ;# and save
     mov       [MaxHeads],dh           ;# Heads save
     mov       si,Loading              ;# print
     call      _print                  ;#  on screen
     call      _detectcpu              ;# Detecting CPU for 386+
_loading:
     mov       cx,0x0002               ;# CHS = 0,0,2 (skip boot sector)
     xor       dh,dh                   ;# Head = 0
     mov       dl,[Drive]              ;# DL:= Drive Number (0-A, 1-B)
     mov       si,0x40                 ;# 40H:=64
     mov       ax,0x1000               ;# destination
     mov       es,ax                   ;# segment - es:bx
     xor       bx,bx                   ;# bx must be 0
     xor       di,di                   ;# di->bx
     call      _readsector             ;# read!
;# **************************************
;# Start modifing here....
floppy_off:
     mov     dx, 0x3F2           
     mov     al, 0
     out     dx, al

;# Enable A20 Gate
     in        al,0x92
     or        al,2
     out       0x92,al

_set_pmode:
     cli
     lgdt      [gdtr]
     mov       eax,cr0
     or        al,1
     mov       cr0,eax
     jmp       0x08:_pmode
use32
_pmode:
     mov       ax,0x10
     mov       ds,ax
     mov       ss,ax
     mov       es,ax
     mov       fs,ax
     mov       gs,ax
     mov       esp,0xFFFC

     jmp       0x08:0x10000           ;# jump to kernel
   
;#     mov       si,ErrorMsg ;;; removing this
;#     call      _print ;;; and this
     hlt                               ;# System halt
     jmp       $                       ;# Forever Cycle

gdt:
     dw  0x0000, 0x0000, 0x0000, 0x0000
codesel:
     dw  0xFFFF, 0x0000, 0x9800, 0x00CF
datasel: 
     dw  0xFFFF, 0x0000, 0x9200, 0x00CF
gdt_end:
gdtr: 
     dw  gdt_end - gdt - 1
     dd  gdt

     times     0x1fe-($-$$) db 0x90    ;# all "unused" bytes - NOP 
     dw        0xAA55                  ;# signature for correct boot
    


and Kernel code:
Code:

Bits 32     ;# here 
org 0x10000
     jmp       _start

gdt:
db   0,0,0,0,0,0,0,0

db   0xFF,0xFF ;# Limit FFFF
db   0x00,0x00 ;# Base Low
db   0x00,0x9A ;# Base med,Type Code
db   0xCF,0x00 ;# Access, base high
;# modifing ... ^^^^^^^^^^^^^

db   0xFF,0xFF ;# Limit FFFF
db   0x00,0x00 ;# Base Low
db   0x00,0x92 ;# Base med,Type Data
db   0xCF,0x00 ;# Access, base high

set_gdt:
dw   set_gdt - gdt - 1 
dd   gdt
Text db 'Switching to Protect Mode... [ok]',0 ;# Just Work!  Wink 
cursor dd 0

_start:
;# removing the previous code...
     lgdt      [set_gdt]
     mov       ecx,cr0
     or        cl,1
     mov       cr0,ecx

     mov       ax,0x10
     mov       ds,ax
     mov       es,ax
     mov       fs,ax
     mov       ss,ax
     mov       esp,0x90000

     jmp       0x08:_protect
_protect:
     mov       esi,Text
     call      kputs

quit:
     
     halt
     jmp       short $

kputs:
     pusha
.loop:  
     lodsb 
     test al, al
     jz quit

     mov ecx, [cursor]
     mov [0xB8000+ecx*2], al
     inc dword [cursor]
     jmp short .loop
    


LokiOS (official name Very Happy ) works!!! I am happy! Razz

Thank's all for the help! (and source code of BOS v0.3!)
Post 24 Aug 2005, 10:38
View user's profile Send private message Visit poster's website Reply with quote
hendryten



Joined: 18 Apr 2005
Posts: 8
Location: Jakarta
hendryten 19 Sep 2005, 11:49
hello all...
I wanna ask about the LIMIT field of the GDT/LDT...

say, if I have the LIMIT field set to 0xFFFF (including the Granularity), what would it means??

the limit of the entry is 0xFFFF bytes?
or
the limit of the entry is below address 0xFFFF ???

thx...

_________________
If you want everything, you'll end up with nothing
Post 19 Sep 2005, 11:49
View user's profile Send private message Yahoo Messenger Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach 20 Sep 2005, 16:43
One GDT selector doesn't have enougth space to hold the entire limit address, so what the granularity bit does is that it multiplices the specified limit with 4kb if it's on.
See here for more information: http://osdever.net/tutorials/brunmar/tutorial_02.php?the_id=18
Post 20 Sep 2005, 16:43
View user's profile Send private message Reply with quote
hendryten



Joined: 18 Apr 2005
Posts: 8
Location: Jakarta
hendryten 21 Sep 2005, 04:24
bubach wrote:
One GDT selector doesn't have enougth space to hold the entire limit address, so what the granularity bit does is that it multiplices the specified limit with 4kb if it's on.
See here for more information: http://osdever.net/tutorials/brunmar/tutorial_02.php?the_id=18


that's not excatly what i'm asking...thx anyway....

What I'm asking is what the LIMIT field means....does it represent the highest address possible or number of bytes possible....

sorry...i don't speak english well...

_________________
If you want everything, you'll end up with nothing
Post 21 Sep 2005, 04:24
View user's profile Send private message Yahoo Messenger Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio 21 Sep 2005, 09:53
hendryten wrote:
What I'm asking is what the LIMIT field means....does it represent the highest address possible or number of bytes possible....

sorry...i don't speak english well...

number of bytes+1 or number of 4KB blocks+1
Post 21 Sep 2005, 09:53
View user's profile Send private message Visit poster's website Reply with quote
hendryten



Joined: 18 Apr 2005
Posts: 8
Location: Jakarta
hendryten 24 Sep 2005, 11:20
i see....thx thx!! Very Happy

_________________
If you want everything, you'll end up with nothing
Post 24 Sep 2005, 11:20
View user's profile Send private message Yahoo Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.