How do i convert a void* to a unsigned long*?

Programming, for all ages and all languages.
Post Reply
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

How do i convert a void* to a unsigned long*?

Post by DixiumOS »

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?
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
User avatar
hgoel
Member
Member
Posts: 89
Joined: Sun Feb 09, 2014 7:11 pm
Libera.chat IRC: hgoel
Location: Within a meter of a computer

Re: How do i convert a void* to a unsigned long*?

Post by hgoel »

By reading up on function pointers and seeing what extra stuff you you have there.
"If the truth is a cruel mistress, than a lie must be a nice girl"
Working on Cardinal
Find me at [url=irc://chat.freenode.net:6697/Cardinal-OS]#Cardinal-OS[/url] on freenode!
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: How do i convert a void* to a unsigned long*?

Post by dozniak »

DixiumOS wrote:How would i convert this?
Keep in mind, this forum is not for teaching beginner-level programming topics.
Learn to read.
User avatar
dchapiesky
Member
Member
Posts: 204
Joined: Sun Dec 25, 2016 1:54 am
Libera.chat IRC: dchapiesky

Re: How do i convert a void* to a unsigned long*?

Post by dchapiesky »

assembly language would be a superior way of accomplishing this task
Plagiarize. Plagiarize. Let not one line escape thine eyes...
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: How do i convert a void* to a unsigned long*?

Post by DixiumOS »

Looks like i get invalid void expression every time i try to do

Code: Select all

&(uint32_t)isr[num]()
or

Code: Select all

&(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.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: How do i convert a void* to a unsigned long*?

Post by DixiumOS »

Finally fixed it.

I had to make my function type an int then in the function do

Code: Select all

(unsigned)isr[num]()
.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: How do i convert a void* to a unsigned long*?

Post by Octocontrabass »

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.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: How do i convert a void* to a unsigned long*?

Post by DixiumOS »

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
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: How do i convert a void* to a unsigned long*?

Post by Octocontrabass »

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.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: How do i convert a void* to a unsigned long*?

Post by DixiumOS »

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.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: How do i convert a void* to a unsigned long*?

Post by Octocontrabass »

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).
User avatar
hgoel
Member
Member
Posts: 89
Joined: Sun Feb 09, 2014 7:11 pm
Libera.chat IRC: hgoel
Location: Within a meter of a computer

Re: How do i convert a void* to a unsigned long*?

Post by hgoel »

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.
"If the truth is a cruel mistress, than a lie must be a nice girl"
Working on Cardinal
Find me at [url=irc://chat.freenode.net:6697/Cardinal-OS]#Cardinal-OS[/url] on freenode!
Post Reply