Board.KolibriOS.org

Official KolibriOS board
It is currently Wed Oct 16, 2019 8:12 am

All times are UTC+03:00




Post new topic  Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Mon Feb 17, 2014 8:02 pm 
Offline

Joined: Fri Oct 18, 2013 9:57 am
Posts: 8
If my program contains in out instructions and I want debug it using kolibri debugger Mtdbg, I get ??? at memory locations where I have thses instructions and when exection reaches these instructions I get this message Debugged Program Caused an exception 0D.Suspended.
Why is this heppening?
Could any body help?


Top
   
PostPosted: Mon Feb 17, 2014 10:04 pm 
Offline
Kernel Developer

Joined: Sun Feb 10, 2013 12:37 pm
Posts: 2329
If you watch the source code debugger, a message is issued in the following cases:
Code:
    ; int3 command generates exception 0D, #GP

or
Code:
    ; check for 0xCC byte at eip

_________________
Всем чмоки в этом проекте! Засуньте эти 11 лет себе в жопу!


Top
   
PostPosted: Mon Feb 17, 2014 10:35 pm 
Offline
Kernel Developer
User avatar

Joined: Thu Sep 03, 2009 1:52 pm
Posts: 1621
in and out instructions are privileged. User-mode code is not allowed to use them, they are intended for the kernel and drivers.

_________________
Сделаем мир лучше!


Top
   
PostPosted: Tue Feb 18, 2014 9:23 am 
Offline

Joined: Fri Oct 18, 2013 9:57 am
Posts: 8
This means I cannot debug my code if it contains these instructions?There is no way to do that?


Top
   
PostPosted: Tue Feb 18, 2014 10:03 am 
Offline
Kernel Developer
User avatar

Joined: Fri Aug 14, 2009 1:46 am
Posts: 1346
Mohsen47
Your application can request port i/o permissions with fn 46.
Alternatively, you can easily modify your Kernel to enable any in/out command in the userspace.


Top
   
PostPosted: Tue Feb 18, 2014 11:38 am 
Offline

Joined: Fri Oct 18, 2013 9:57 am
Posts: 8
art_zh
Thanks for the tip it worked well, but there is a little problem I tried to reserve the io port range for pci from 0xcf8 to 0xcfc and I was able to write a double word to pci config register but when I try to read a double word from pci data register I get the same exception, I am only able to read a word from data register, why is this?


Top
   
 Post subject:
PostPosted: Tue Feb 18, 2014 1:16 pm 
Offline
Public Relations
User avatar

Joined: Mon Jun 07, 2010 12:01 pm
Posts: 1879
If you attach your full source code, it would be much easier to help you.


Top
   
PostPosted: Tue Feb 18, 2014 2:57 pm 
Offline
Kernel Developer
User avatar

Joined: Fri Aug 14, 2009 1:46 am
Posts: 1346
Mohsen47
PCI ports are restricted system resources.
Use fn 62 to access PCI configspace
(in Kolibri-A you will also enjoy MMIO access to the Extended PCIe configspace, but it only runs on AMD Fusion).


Top
   
PostPosted: Tue Feb 18, 2014 5:22 pm 
Offline

Joined: Fri Oct 18, 2013 9:57 am
Posts: 8
Thanks for your interest guys.
This is my simple code:
Code:
mov eax,46
mov ebx,0
mov ecx,0xcf8
mov edx,0xcfd
int 0x40
cmp eax,1
je exit
mov eax,0x80001800 ;get the vendor and device id for device number 3 in pci bus number 0 which is my network interface.
mov dx,0xcf8
out dx,eax
mov dx,0xcfc
in dx,eax
exit:


This code doesn't work and gives me the same exception at
Code:
 in dx,eax 
instruction but if I replace it with
Code:
 in ax,dx 
it works and allows me to read the vendor id only in the lower two bytes of eax but I cannot get the device id.

I don't want to use fn 62 to access PCI configspace because I want to move this code to my OS so I want to accomplish this only using assembly instruction that are provided in every assembler, I am using kolbri because it is simple and allows me to debug the assembly code very easily.


Top
   
PostPosted: Tue Feb 18, 2014 5:31 pm 
Offline
Kernel Developer

Joined: Sun Feb 10, 2013 12:37 pm
Posts: 2329
Mohsen47 wrote:
I don't want to use fn 62 to access PCI configspace because I want to move this code to my OS so I want to accomplish this only using assembly instruction that are provided in every assembler, I am using kolbri because it is simple and allows me to debug the assembly code very easily.

Probably it will help to you:
core/taskman.inc
Code:
mov     [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF

Change EFL_IOPL1 to EFL_IOPL3 and compile the kernel.

_________________
Всем чмоки в этом проекте! Засуньте эти 11 лет себе в жопу!


Top
   
PostPosted: Tue Feb 18, 2014 7:32 pm 
Offline

Joined: Fri Oct 18, 2013 9:57 am
Posts: 8
Thanks Mario_r4.
Actually I don't have all the source code on my computer but when I have it I will try what you said, really thanks a lot.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 11 posts ] 

All times are UTC+03:00


Who is online

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited