Mtdbg and in out instructions.

Assembler programming questions
  • If you watch the source code debugger, a message is issued in the following cases:

    Code: Select all

        ; int3 command generates exception 0D, #GP
    or

    Code: Select all

        ; check for 0xCC byte at eip
    Всем чмоки в этом проекте! Засуньте эти 11 лет себе в жопу!
  • in and out instructions are privileged. User-mode code is not allowed to use them, they are intended for the kernel and drivers.
    Сделаем мир лучше!
  • This means I cannot debug my code if it contains these instructions?There is no way to do that?
  • 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.
  • 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?
  • If you attach your full source code, it would be much easier to help you.
  • 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).
  • Thanks for your interest guys.
    This is my simple code:

    Code: Select all

    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: Select all

     in dx,eax 
    instruction but if I replace it with

    Code: Select all

     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.
  • 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: Select all

    mov     [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF
    Change EFL_IOPL1 to EFL_IOPL3 and compile the kernel.
    Всем чмоки в этом проекте! Засуньте эти 11 лет себе в жопу!
  • 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.
  • Who is online

    Users browsing this forum: No registered users and 5 guests