Results 1 to 5 of 5

Thread: Setting up function pointers ---> Need help!

  1. #1

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306

    Setting up function pointers ---> Need help!

    Hello.

    I am currently designing the ISA Plug and Play support for my operating system. I have code to detect the ISAPnP BIOS - it gets the address of the certain function...

    ...But how exactly do I set the function prototype to point to the address that the BIOS specifies?

    It took me a while to get the BIOS detect code running, but I think that setting this pointer will be even more bothersome. There are actually 3 different prototypes for the function because it is called 3 different ways, but they ALL point to the same address(Or they are supposed to).

    The following code needs to be set to the address:
    int FAR (*entryPoint)(Function, NumNodes, NodeSize, BiosSelector);
    int Function; /* PnP BIOS Function 0 */
    unsigned char FAR *NumNodes; /* Number of nodes the BIOS will return */
    unsigned int FAR *NodeSize; /* Size of the largest device node */
    unsigned int BiosSelector; /* PnP BIOS readable/writable selector */
    That piece gives the function prototype. Also, the funtion should not be "int FAR" because my OS is protected mode ready, so it should be "unsigned long"(It works better).

    Isn't it something like:

    unsigned long (*entrypointfunc)(Function, numnodes, nodesize, BIOSsel) = (unsigned long *)BIOS->pmode_entrypoint;

    This is a crucial part of my OS, so I request your help as soon as possible...
    Designer/Programmer of the Comtech Operating System(CTOS)

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's a lot easier if you use a typedef, for example:
    Code:
    typedef unsigned long (*entrypointfunc)(Function, numnodes, nodesize, BIOSsel);
    
    entrypointfunc epf = (entrypointfunc)BIOS->pmode_entrypoint;
    ...I think
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    I still can't quite get it to work. As soon as it executes the function pointer, it writes like the whole memory after segment 0xA000(my PMode segment) to the screen. It doesn't quite look that beautiful... I just got super annoyed with the last part of it, so just take a look at this code. Maybe you will understand what I'm trying to do and maybe you can spot my error(-please-)???
    Attached Files Attached Files
    Designer/Programmer of the Comtech Operating System(CTOS)

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I don't understand it but there's one thing...
    You say you are in protected mode, yet you use a 16-bit variable as function pointer. Are you sure this works?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    Yeah, that COULD matter. I'll have to try it out. Hopefully I won't crash my computer doing this.

    Hmmm... It goes Segmentffset, correct? My code gets the segment and the offset. I ran the program on this computer(@ school), and I get PMode segment 0x0000, and PMode offset 0xE2F4. So it would be like this as a 32-bit address: 0000:E2F4

    On my computer it was: 0000:A000, so it really shouldn't matter as we have the lower 16-bits.

    This might matter: To test this program, I need to be in protected mode. I know DOS is real mode, but is a Windows DOS box real or protected mode? I have real mode offsets, so I could need those. It was bothering me yesterday, so I'll need to look into it further today. I got "Error: Call to non-function" and it went to my line where I actually called the info. Parksie's idea did (It was a function or something), but it puts garbage on the screen right when you call it.

    The actual ISAPnP document shows a psuedo-assembler version of the code and the calls. I'm not good with ASM, and I don't know the little compiler sub commands and such, but maybe I can try to just use the assembler code embedded in my C code.

    If you find a solution or a better way of setting this up, it would be much appreciated.
    Designer/Programmer of the Comtech Operating System(CTOS)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width