Passing a C/C++ Pointer to a Different Segment Register (ES/
Posted: Tue Feb 04, 2003 11:26 pm
..
The Place to Start for Operating System Developers
https://forum.osdev.org/
It can be accomplished through a "farptr" structure you have to declare that will look likePerica Senjak wrote: Hey,
What i want to do is Pass a C/C++ Pointer using a Different Segment Register other than "DS";
Can this be accomplished easily in C/C++??The problem is that the compiler will not let you do *farX = 1 in C, but in C++, overloading every operator for the far class, maybe you could handle it ...Code: Select all
struct farptr { void *offset; selector_t segment; }
I'm afraid i don't see what you mean, but i guess you wonder if you can access memory by its virtual address *and* with its physical address. In that case the answer is no.Also, when paging maps a Certain Area Of Memory - Is it Possible to Acess the Memory from Both Addresses: The Pages Address and the Normal One (If you know what i mean)??
The reason is every memory reference will go through the paging chip once paging is enabled (bit 31 in cR0 set) --> if you want to access physical frame #x with paging enabled, you have to
- find out a free page and map it to #x,
- flush the TLB cache for #x,
- do your access,
- unmap the page,
- flush the TLB for #x again.
This is what Clicker's Page Frame Viewer (code here) is about ...
Cya.
eeek! i would not do it that way, if i were you ... because it will mean that every byte access will require a function call that the processor will never be able to optimize.I'll write a Linked Assembler Function that Simply writes a Specified Byte/Word/dWord/qWord of Data to a Specified Register, and a Specified Selector:Offset - Something like this: bool WriteFS_dWord(unsigned int Selector, unsigned int Offset, unsigned short Data);
The main reason i use them is simply to remind me of their presence and of the evil fact they'll be inlined only when optimizations are turned on ...
The alternate keywords `__asm__', `__extension__', `__inline__'
and `__typeof__' continue to work despite `-ansi'. You would not
want to use them in an ANSI C program, of course, but it is useful
to put them in header files that might be included in compilations
done with `-ansi'. Alternate predefined macros such as `__unix__'
and `__vax__' are also available, with or without `-ansi'.