Page 1 of 1

Mapping Memory

Posted: Sat Oct 18, 2008 5:49 am
by whiteOS
not sure if anyone can help me this. i want map memory space of device in kernel space. how I do?

Re: Mapping Memory

Posted: Sat Oct 18, 2008 3:31 pm
by Combuster
Er, with paging?

Re: Mapping Memory

Posted: Sat Oct 18, 2008 7:50 pm
by whiteOS
Er, that is what I was doing before when you said I was wrong! In fact in another thread I spoke:

Code: Select all

#define GET_PAGE_NUMBER( address ) ( address >> 12 )
void map_mem(unsigned int base, unsigned int length)
{
   page_t *pg;
   
   //create pd
   kernel_directory = (page_directory_t*)kmalloc_a(sizeof(page_directory_t));
    memset(kernel_directory, 0, sizeof(page_directory_t));
   
    int i = 0;
   //create pages
    for (i = base; i < base+length; i += 0x1000)
        get_page(i, 1, kernel_directory);

   //identity map
    i = 0;
    while (i < base+0x1000)
    {
        // Kernel code is readable but not writeable from userspace.
        alloc_frame( get_page(i, 1, kernel_directory), 0, 0);
        i += 0x1000;
    }

    // Now allocate those pages we mapped earlier.
    for (i = base; i < base+length; i += 0x1000)
        alloc_frame( get_page(i, 1, kernel_directory), 0, 0);

   //set frame to base addr
   pg->frame=GET_PAGE_NUMBER(base);
}
I told you that it crash my OS and I say what is wrong with it. And you say, looks like you are attempting map of MMIO and you made confused me and said I yes, that is what I am trying to do, but what I was trying to do was map a memory space as the threads title suggested, but you confused and mislead me so I agreed foolishly and wasted time.

the point is that this code does not work without crashing me which means it never mapped the address, so what is wrong with my code that would cause it to crash. Are my questions beyond the scope of this forum as I not get much help here?

Re: Mapping Memory

Posted: Sun Oct 19, 2008 2:16 am
by kmtdk
In oder to help, we will need the full code ( kmalloc_a, and sutch things ).
The point with this foum is not to do your code, but to help eithor, and "out of the scope" , well that depense on how you set up the question, because you can ask foolish, and then noby understand what you mean.


KMT dk

Re: Mapping Memory

Posted: Mon Oct 20, 2008 3:36 am
by Combuster
The point is, you are using some code you don't seem to understand what it does, and then you try to use it for something else which is not what the code was meant to do.

And it seems to have happened the same with the used terminology: I said something, and you didn't understand but instead pretended to do so anyway. Of course subsequent attempts to help won't work at that point. And to be honest, I'm rather appalled by the fact that you claim that I gave the wrong info when you say that you never understood it.

Since you finally told us it is the basics you do not understand, we can give more useful responses. Start by reading up on Paging Setting_Up_Paging and rereading the tutorial where you grabbed that code from (and please do tell us in detail what you think it is meant to do so we can fix that too if necessary)

Re: Mapping Memory

Posted: Mon Oct 20, 2008 4:37 am
by egos
:twisted:

[-o<

It's easy to do if you know the physical address of hardware buffer and have the sequential reserved area with suitable size in kernel space. For example:

Code: Select all

  cld
  mov eax,0A0000h or PF_GLOBAL or PF_PCD or PF_WRITABLE or PF_PRESENT
  mov ecx,128/4
  mov edi,PTable+GET_PAGE_NUMBER(VFB)*4
@@:
  stosd
  add eax,1000h
  loop @b

Re: Mapping Memory

Posted: Mon Oct 20, 2008 10:44 pm
by whiteOS
how far off am I from being correct? i present a prototype for you to examine. may you examine it? i hope I provide you the right pieces if even in excess. my effort is purely educational now as my computer has died and I am not able to test my driver now. i got six years out of it and i happy it dead now. now i get laptop. :)

Re: Mapping Memory

Posted: Tue Oct 21, 2008 1:07 am
by egos
My congratulations to you. No driver, no problems :roll: Or the driver is still living :shock:

Re: Mapping Memory

Posted: Tue Oct 21, 2008 1:43 am
by whiteOS
currently alive in the paradigm of my mind. physically offline for now.

Re: Mapping Memory

Posted: Tue Oct 21, 2008 1:56 am
by egos
You are just philosophist :)

P.S. I'm sorry for offtop.