How can i make my lidt/lgdt accept structs?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

How can i make my lidt/lgdt accept structs?

Post by NunoLava1998 »

I am loading the IDT and GDT. However, when i try to put a struct into my lidt and lgdt functions:

Code: Select all

static inline void lidt(void* base, uint16_t size)
{   // This function works in 32 and 64bit mode
    struct {
        uint16_t length;
        void*    base;
    } __attribute__((packed)) IDTR = { size, base };
 
    asm volatile ( "lidt %0" : : "m"(IDTR) );  // let the compiler choose an addressing mode
}

void lgdt(void* base, uint16_t size){
	struct {
		uint16_t length;
		void* base;
	} __attribute__((packed)) GDTR = { size, base };
	
	asm volatile ("lgdt %0" : : "m"(GDTR) );
}
and try to insert my struct:

Code: Select all

lidt(struct idt_description);
lgdt(struct gdt_description);
I get errors and warnings that all relate to the function expecting 2 functions, but only being given 1.
How can i recode my lidt and lgdt instructions to accept only 1 instruction?

Oh, and no code and no arguing. I already know how to make code by myself. Unless it's extra difficult, you do not need to provide code.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: How can i make my lidt/lgdt accept structs?

Post by Kevin »

The functions are declared to take a void* and a uint16_t. You're passing it a... type name or something? That's not quite the same.

And this is really just basic C, not related to OSes at all.
Developer of tyndur - community OS of Lowlevel (German)
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How can i make my lidt/lgdt accept structs?

Post by NunoLava1998 »

Kevin wrote:The functions are declared to take a void* and a uint16_t. You're passing it a... type name or something? That's not quite the same.

And this is really just basic C, not related to OSes at all.
sorry. i'm trying to pass a struct
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: How can i make my lidt/lgdt accept structs?

Post by Love4Boobies »

I think all of us on the forum would do him a huge favour if we stopped answering his questions. This one is simply embarrassing; he doesn't understand the semantics of procedure calls---one of the simplest and most fundamental things anyone can learn in programming. He doesn't want want to read like 200 pages of text that would teach him C in a couple of days. He would be done with K&R by now. But no, instead, he wants to spend eternity asking the most stupid questions about each and every line of code (sometimes he doesn't even understand the questions he is asking, let alone the answers).
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How can i make my lidt/lgdt accept structs?

Post by iansjack »

+1
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How can i make my lidt/lgdt accept structs?

Post by NunoLava1998 »

yeah, i'm gonna start adding some people as foes

i'm pretty sure only sortie and glauxosdever have actually realized i've started to write code myself
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
glauxosdever
Member
Member
Posts: 501
Joined: Wed Jun 17, 2015 9:40 am
Libera.chat IRC: glauxosdever
Location: Athens, Greece

Re: How can i make my lidt/lgdt accept structs?

Post by glauxosdever »

Hi,

NunoLava1998 wrote:yeah, i'm gonna start adding some people as foes
This doesn't benefit you at all. Unless they are disrupting and/or insulting and have nothing good to give you, there is no point in adding them as foes; they still have something useful to say.
NunoLava1998 wrote:i'm pretty sure only sortie and glauxosdever have actually realized i've started to write code myself
Maybe you started to write code yourself, but you can't write correct code without help. I suggest you learn C.


Regards,
glauxosdever
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: How can i make my lidt/lgdt accept structs?

Post by osdever »

NunoLava1998 wrote:
Kevin wrote:The functions are declared to take a void* and a uint16_t. You're passing it a... type name or something? That's not quite the same.

And this is really just basic C, not related to OSes at all.
sorry. i'm trying to pass a struct
Just learn C. Please. I'm tired of all these questions.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: How can i make my lidt/lgdt accept structs?

Post by Solar »

Seconded. Kernel space is not the place to learn basics of your programming language of choice.
Every good solution is obvious once you've found it.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: How can i make my lidt/lgdt accept structs?

Post by dozniak »

You guys miss the chance to teach him something that is not C, nor asm, nor it is usable in any way, just for giggles.

Things like "Struct is a mirror of processor registers" or "function calls require heap", all that jazz.

Just imagine the face of his future employer.
Learn to read.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: How can i make my lidt/lgdt accept structs?

Post by Solar »

Being one of those regularly assigned as tutor for newcomers in the office, and having to face the consequences of sub-par preparation for the job, I somewhat fail to see the joke. ( :wink: )

"Getting it right" is so much more satisfying.
Every good solution is obvious once you've found it.
PrivatePecker2
Posts: 1
Joined: Wed Jan 04, 2017 9:46 pm

Re: How can i make my lidt/lgdt accept structs?

Post by PrivatePecker2 »

Hi Nuno, I've noticed that you've been posting on these forums recently, to the annoyance of many, and I am genuinely concerned about your future in programming especially if you seek employment. A simple Google search of your username brings up many embarrassing results on all kinds of forums. All I really want you to do here is to make sure all of your accounts are thoroughly anonymized and it is impossible to connect your real name to your username on any of the many sites you have created accounts on.

Since this is my first post here I also thought I would say hello. I've recently taken up the hobby of OSDeving and like to browse these forums on occasion. Don't expect to hear from me that often, I'm not very social.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: How can i make my lidt/lgdt accept structs?

Post by Schol-R-LEA »

That would be great advice (which I wish I had been given 20 years ago myself) if it weren't for the fact that, given what I have seen when searching on 'nunolava', his username is probably based on his real name. Nuño is a fairly common personal name in Spanish, and Nuno is equally common in Portuguese; while there are several Spanish and Portuguese surnames which start with 'Lava', such as Lavajo and Lavareda.

Thus, while it is not necessarily obvious which of the several individuals on (say) LinkedIn whose names match 'Nuno Lava*' he is, it would probably be fairly easy to narrow it down.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Post Reply