OSDev.org
https://forum.osdev.org/

How do i convert a void* to a unsigned long*?
https://forum.osdev.org/viewtopic.php?f=13&t=31206
Page 1 of 1

Author:  DixiumOS [ Wed Jan 11, 2017 4:06 pm ]
Post subject:  How do i convert a void* to a unsigned long*?

I am trying to load ISR's. However, i have 32 isr(num) void type functions. Since my function only accepts uint32_t's or unsigned long's, i would like to convert my functions to a uint32_t*, unsigned long* or similar.

(the function is just a void, i point to it in the function).
If i try to do (uintptr_t)isr[num]();, it gives "invalid use of void expression".

If i try (uintptr_t*), same thing.

How would i convert this?

Author:  hgoel [ Wed Jan 11, 2017 4:09 pm ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

By reading up on function pointers and seeing what extra stuff you you have there.

Author:  dozniak [ Wed Jan 11, 2017 6:14 pm ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

DixiumOS wrote:
How would i convert this?


Keep in mind, this forum is not for teaching beginner-level programming topics.

Author:  dchapiesky [ Wed Jan 11, 2017 7:54 pm ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

assembly language would be a superior way of accomplishing this task

Author:  DixiumOS [ Thu Jan 12, 2017 12:53 am ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

Looks like i get invalid void expression every time i try to do
Code:
&(uint32_t)isr[num]()
or
Code:
&(unsigned long)isr[num]()

or any other. I'm gonna try to switch my function type to an unsigned int and convert it to a unsigned long (same size) and see if that works.

Author:  DixiumOS [ Thu Jan 12, 2017 1:06 am ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

Finally fixed it.

I had to make my function type an int then in the function do
Code:
(unsigned)isr[num]()
.

Author:  Octocontrabass [ Thu Jan 12, 2017 1:36 am ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

DixiumOS wrote:
Finally fixed it.

No you didn't.

Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way), your code is obviously wrong.

As suggested in an earlier post, you need to research function pointers.

Author:  DixiumOS [ Thu Jan 12, 2017 1:55 am ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

Octocontrabass wrote:
DixiumOS wrote:
Finally fixed it.

No you didn't.

Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way), your code is obviously wrong.

As suggested in an earlier post, you need to research function pointers.


I didn't even need the pointer, anyway. The tutorial also puts (unsigned), but had the wrong types on the other file, i had to tweak things, i got on a completely different road (when i asked this question), and then went to the correct thing.

Now my only error/warning is a one that i can't seem to understand.

"Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way)"
I think you looked at the first few posts, and ignored the entire rest

Author:  Octocontrabass [ Thu Jan 12, 2017 2:18 am ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

DixiumOS wrote:
I didn't even need the pointer, anyway.

So if you don't need the pointer, then what exactly are you putting in your IDT? (And where is your assembly wrapper for your ISRs? You can't do IRET in inline assembly.)

DixiumOS wrote:
Now my only error/warning is a one that i can't seem to understand.

This is why we keep telling you to learn C before you start writing an OS.

DixiumOS wrote:
"Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way)"
I think you looked at the first few posts, and ignored the entire rest

No, I'm looking at your repo. Broken code everywhere.

Author:  DixiumOS [ Thu Jan 12, 2017 2:28 am ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

Octocontrabass wrote:
DixiumOS wrote:
"Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way)"
I think you looked at the first few posts, and ignored the entire rest

No, I'm looking at your repo. Broken code everywhere.


I still haven't updated that.

Author:  Octocontrabass [ Thu Jan 12, 2017 2:50 am ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

Now you've updated it, but your code is still broken. You still aren't using function pointers correctly (and even if you were, you still can't use IRET in inline assembly).

Author:  hgoel [ Thu Jan 12, 2017 10:07 am ]
Post subject:  Re: How do i convert a void* to a unsigned long*?

Octocontrabass wrote:
Now you've updated it, but your code is still broken. You still aren't using function pointers correctly (and even if you were, you still can't use IRET in inline assembly).

Technically you can, it just needs a lot more care. Agreed on the rest though.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/