Mapping Memory
Mapping Memory
not sure if anyone can help me this. i want map memory space of device in kernel space. how I do?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Mapping Memory
Er, with paging?
Re: Mapping Memory
Er, that is what I was doing before when you said I was wrong! In fact in another thread I spoke:
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?
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);
}
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
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
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
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Mapping Memory
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)
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
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
If you have seen bad English in my words, tell me what's wrong, please.
Re: Mapping Memory
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
My congratulations to you. No driver, no problems Or the driver is still living
If you have seen bad English in my words, tell me what's wrong, please.
Re: Mapping Memory
currently alive in the paradigm of my mind. physically offline for now.
Re: Mapping Memory
You are just philosophist
P.S. I'm sorry for offtop.
P.S. I'm sorry for offtop.
If you have seen bad English in my words, tell me what's wrong, please.