OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 3:54 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: How do i convert a void* to a unsigned long*?
PostPosted: Wed Jan 11, 2017 4:06 pm 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
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


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Wed Jan 11, 2017 4:09 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 09, 2014 7:11 pm
Posts: 89
Location: Within a meter of a computer
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 #Cardinal-OS on freenode!


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Wed Jan 11, 2017 6:14 pm 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
DixiumOS wrote:
How would i convert this?


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

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Wed Jan 11, 2017 7:54 pm 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 204
assembly language would be a superior way of accomplishing this task

_________________
Plagiarize. Plagiarize. Let not one line escape thine eyes...


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Thu Jan 12, 2017 12:53 am 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
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.

_________________
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Thu Jan 12, 2017 1:06 am 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
Finally fixed it.

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

_________________
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Thu Jan 12, 2017 1:36 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
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.


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Thu Jan 12, 2017 1:55 am 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
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


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Thu Jan 12, 2017 2:18 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
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.


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Thu Jan 12, 2017 2:28 am 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
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


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Thu Jan 12, 2017 2:50 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
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).


Top
 Profile  
 
 Post subject: Re: How do i convert a void* to a unsigned long*?
PostPosted: Thu Jan 12, 2017 10:07 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 09, 2014 7:11 pm
Posts: 89
Location: Within a meter of a computer
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 #Cardinal-OS on freenode!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group