Can't get GRUB to pass memory map

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
anonlalo
Posts: 8
Joined: Sat Mar 05, 2011 9:36 pm

Can't get GRUB to pass memory map

Post by anonlalo »

hey guys, I've been setting bit 6 of the multiboot flags for grub, which should cause it to pass me a memory map according to the documentation. It is not doing this.

I have been using the pre-made floppy with grub installed, which I downloaded from the James Molloy tutorial.

Wondering if anyone else has experienced this before... Is this my version of grub not supporting this?

I am using this line to set the flags:
MBOOT_HEADER_FLAGS equ 1000001b

Also, would it be possible/practical after being booted into protected mode by grub, to drop down into unreal mode and use the bios interupts to grab the memory map myself?
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Can't get GRUB to pass memory map

Post by gerryg400 »

anonlalo wrote:hey guys, I've been setting bit 6 of the multiboot flags for grub, which should cause it to pass me a memory map according to the documentation. It is not doing this.

I have been using the pre-made floppy with grub installed, which I downloaded from the James Molloy tutorial.

Wondering if anyone else has experienced this before... Is this my version of grub not supporting this?

I am using this line to set the flags:
MBOOT_HEADER_FLAGS equ 1000001b

Also, would it be possible/practical after being booted into protected mode by grub, to drop down into unreal mode and use the bios interupts to grab the memory map myself?
Make sure you are using grub 0.97 ? Grub 0.96 cannot detect memory on my newest PC.
If a trainstation is where trains stop, what is a workstation ?
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Can't get GRUB to pass memory map

Post by jal »

anonlalo wrote:Also, would it be possible/practical after being booted into protected mode by grub, to drop down into unreal mode and use the bios interupts to grab the memory map myself?
Of course it would, although you just need real, not unreal, mode.


JAL
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: Can't get GRUB to pass memory map

Post by Tosi »

I would recommend creating your own floppy with a more recent version of GRUB and see if that works.
Also, check if GRUB is sending a NULL pointer for the memory map or not. If it isn't, it probably is passing it correctly. If you are using a higher-half kernel or otherwise have paging enabled when you try to parse the memory map, make sure you convert its physical address into the correct linear address.
anonlalo
Posts: 8
Joined: Sat Mar 05, 2011 9:36 pm

Re: Can't get GRUB to pass memory map

Post by anonlalo »

So, I got grub 1.98 installed on a usb, and I booted it on my netbook... I'm getting this from grub:

Code: Select all

error: unsupported flag: 0x41
error: no loaded kernel.

Press any key to continue..._
I really am lost, as the documentation I am reading on multiboot specification says this should be working. this is where i am looking mostly: http://www.gnu.org/software/grub/manual ... iboot.html

I have also tried looking for examples or explanations in the forum with no luck. Anyone know what is going on here?

Code: Select all

MBOOT_FLAGS equ 1000001b
MBOOT_MAGIC	equ 0x1BADB002
MBOOT_CHKSUM equ -(MBOOT_HEADER_MAGIC + MBOOT_HEADER_FLAGS)


mboot:
dd MBOOT_MAGIC
dd MBOOT_FLAGS
dd MBOOT_CHKSUM

Now if I change "MBOOT_FLAGS equ 1000001b" to "MBOOT_FLAGS equ 1", it boots fine, so I am pretty sure it's not my header format. Hoping someone has figured out this before. Also, I have tried this on VMware player, bochs, and my netbook so I don't think it's hardware incompatibility or I would have found some forum posts asking about it.
anonlalo
Posts: 8
Joined: Sat Mar 05, 2011 9:36 pm

Re: Can't get GRUB to pass memory map

Post by anonlalo »

Grub 2 (version 1.98) uses a different (incompatible) multiboot standard implementation.
Could you offer a little more details. Do you know a specific version of grub that does support full multiboot spec, or another bootloader which will work?
anonlalo
Posts: 8
Joined: Sat Mar 05, 2011 9:36 pm

Re: Can't get GRUB to pass memory map

Post by anonlalo »

Okay, so bit 1 sends mmap info... which does not line up with the docs...
Is it still the same structure it passes? this is the one I found it somewhere somewhere, forget where:

Code: Select all

struc multiboot_info
	.flags		resd	1
	.memoryLo	resd	1
	.memoryHi	resd	1
	.bootDevice	resd	1
	.cmdLine	resd	1
	.mods_count	resd	1
	.mods_addr	resd	1
	.syms0		resd	1
	.syms1		resd	1
	.syms2		resd	1
	.mmap_length	resd	1
	.mmap_addr	resd	1
	.drives_length	resd	1
	.drives_addr	resd	1
	.config_table	resd	1
	.bootloader_name resd	1
	.apm_table	resd	1
	.vbe_control_info resd	1
	.vbe_mode_info	resd	1
	.vbe_mode	resw	1
	.vbe_interface_seg resw	1
	.vbe_interface_off resw	1
	.vbe_interface_len resw	1
endstruc
I'm just writing my own bootloader... I don't like the fact that grub doesn't work the way it's documented to... and I'm having other problems that I think are related to grub too so I want to have total control over the environment, but I still would like to figure this out for my own sanity.
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: Can't get GRUB to pass memory map

Post by Tosi »

GRUB works the way it's supposed to, so long as you tell it what you want correctly.
Depending on how you look at it, you were either using the wrong version of GRUB or the wrong version of the multiboot specification.
Most other problems with GRUB have the same source: the multiboot header isn't aligned correctly, it's not early enough in the kernel binary, it's a non-ELF kernel without the AOUT kludge, the linker script was incorrect, etc. Did you check to make sure you were doing all that correctly?

Trying to write your own bootloader is a good way to lose your sanity, not that us OS developers have much in the first place.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Can't get GRUB to pass memory map

Post by Solar »

anonlalo wrote:I'm just writing my own bootloader... I don't like the fact that grub doesn't work the way it's documented to... and I'm having other problems that I think are related to grub too so I want to have total control over the environment, but I still would like to figure this out for my own sanity.
Behold a prime example of NIH syndrome. Prove, don't assume, before you decide to roll-your-own.

Your chances at doing better than any one well-established project are slim. Pick your battle - writing a better GRUB is a good-sized project for a single person all in itself. Wouldn't it be a shame if it turned out the sole reason why you sunk countless hours in developing and debugging a bootloader is a failure to use e.g. GRUB correctly?
Every good solution is obvious once you've found it.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Can't get GRUB to pass memory map

Post by jal »

Fwiw, I have never had any problem getting GRUB to do what I wanted. Given the fact that I'm an average, out of practice developer, that makes me hold those who claim to have problems with it in very low regard...

JAL
anonlalo
Posts: 8
Joined: Sat Mar 05, 2011 9:36 pm

Re: Can't get GRUB to pass memory map

Post by anonlalo »

re-read. fixed problems. Thanks for your guys inputs. The problems were arising from a) my being confused by different versions of grub and the multiboot spec and b) I had set some other stuff up wrong and it didn't come to light until now.

And in regards to holding programmers in low regard who can't figure this stuff out. Try searching through wikis and documentation and finding what you need when you have dyslexia. I wasn't asking for anyone to write code for me, I was just asking for some direction as to where to look, because after a couple days of reading the documentation I knew I was in the wrong place. Other than to make me feel bad about myself, and to reinfroce your feeling of superiority over others, I'm really not sure what the point of that comment was.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Can't get GRUB to pass memory map

Post by Solar »

anonlalo wrote:And in regards to holding programmers in low regard who can't figure this stuff out. Try searching through wikis and documentation and finding what you need when you have dyslexia.
A condition that was anything but obvious from your posts so far. You may consider this a compliment.

Unfortunately it's not much of an excuse. Either one decides that a certain condition doesn't hinder him being a good programmer, in which case he shouldn't excuse yourself with it. Or he decides that it does hinder him, in which case he should look for a different hobby. (And yes, I know what I'm talking about, as my wife is both dyslexic and a SCJP.)

The upside of it is that programmers tend to be a community judging by achievement only. You may be a kid, a chain-smoking transsexual, you may look like you could use a shower and a haircut, you may look like a maniac who is a night's sleep short and made up for it with a beer too many(*). Doesn't matter, as long as you're skilled.

(*): That's actually me, at a demo party six years ago. I don't claim to be en par with Bunten or Stallman, I was just looking for another "weird" photo. :wink:
Every good solution is obvious once you've found it.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Can't get GRUB to pass memory map

Post by jal »

anonlalo wrote:And in regards to holding programmers in low regard who can't figure this stuff out. Try searching through wikis and documentation and finding what you need when you have dyslexia.
Dyslexia is no excuse, as Solar already pointed out. If dyslexia keeps you from being able to program, then don't program.
Other than to make me feel bad about myself
If you are feeling bad because of a single comment on the internet, you'd better nog get on-line.
and to reinfroce your feeling of superiority over others
I place myself at the bottom of the scale among the more experienced developers here, and in no way I feel superior in general. It is no achievement though feeling "superior" (your word) over anyone that can't read a very-easy-to-digest spec anc complains about it.
I'm really not sure what the point of that comment was.
Good question, neither do I.


JAL
anonlalo
Posts: 8
Joined: Sat Mar 05, 2011 9:36 pm

Re: Can't get GRUB to pass memory map

Post by anonlalo »

Dyslexia is no excuse, as Solar already pointed out. If dyslexia keeps you from being able to program, then don't program.
Solar wasn't a jerk about it.
If you are feeling bad because of a single comment on the internet, you'd better nog get on-line.
Most people with disabilities feel bad when they are discriminated against.

Yourself jal, and to a lesser extent solar have given a perfect example of ableism. You think that because I have a disadvantage in this field (or any other that requires a lot of reading) that I shouldn't attempt to try it. Why don't you go one further and say that no disabled person should ever try anything if they know they won't do it as well and a non-disabled person.

I love coding in assembly, and I have wanted to write my own OS since I was 11 or 12 when I first taught myself C and I won't let some elitist developers discourage me because I have a disability(actually many) that puts me at a disadvantage over others.
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: Can't get GRUB to pass memory map

Post by Tosi »

They aren't saying to not try because you have a disability, but not to use that as an excuse when you are unable to do something.
If anything they are encouraging you to try despite your disability, and I encourage you to do so as well.

The problem seems to be not that you weren't reading the documentation, but that you were reading the wrong documentation. The documentation for GRUB should say the version number at the top. If it is >1.0 then it is not Legacy.

I do agree that this community is slightly elitist, but they have reason to be. Writing an OS is one of the most complicated and advanced programming tasks there is, and having any kind of success in it says a lot about one's programming skills. Similarly, not being able to write an OS doesn't mean one is a bad programmer.
Post Reply