Memory Allocation
- JackScott
- Member
- Posts: 1036
- Joined: Thu Dec 21, 2006 3:03 am
- Location: Hobart, Australia
- Mastodon: https://aus.social/@jackscottau
- Matrix: @JackScottAU:matrix.org
- GitHub: https://github.com/JackScottAU
- Contact:
Brendan has already done that, and posted his impression in these forums several times:
Brendan wrote: IMHO the memory detection code used by GRUB isn't very good. The methods it uses are:
Try BIOS Int 0x15, eax = 0xE820
If that didn't work, try BIOS Int 0x15, ax = 0xE801 and BIOS Int 0x12
If that didn't work, try BIOS Int 0x15, ah = 0x88 and BIOS Int 0x12
Linux is the same, except that it handles the RBIL bugs in e801 and e88
Well, Grub is aimed at modern machines I guess, so I don't see any problem there. Perhaps it would fail on old ones, but still, those BIOS calls should provide enough information.bewing wrote:Brendan has already done that, and posted his impression in these forums several times:Brendan wrote: IMHO the memory detection code used by GRUB isn't very good.
JAL
I detect memory in realmode, using some BIOS-routines.
When the memory-map function fails (unsupported by older BIOSes), I use fallback functions. If you like, I can post the code here (when I'm at home).
In many OS-projects I see a switch to realmode very soon. Most OS-projects doesn't do anything in realmode. That's ok, but sometimes the BIOS can be very helpful. For example determing the amount of memory, and the memory-map, safe and compatible. But also for getting information for calling VESA-routines from protected mode. I put all that information in a block of memory, so the kernel can use that in protected mode. Most important part is the memory information.
When the memory-map function fails (unsupported by older BIOSes), I use fallback functions. If you like, I can post the code here (when I'm at home).
In many OS-projects I see a switch to realmode very soon. Most OS-projects doesn't do anything in realmode. That's ok, but sometimes the BIOS can be very helpful. For example determing the amount of memory, and the memory-map, safe and compatible. But also for getting information for calling VESA-routines from protected mode. I put all that information in a block of memory, so the kernel can use that in protected mode. Most important part is the memory information.
Last edited by svdmeer on Wed May 14, 2008 5:57 am, edited 1 time in total.
- JackScott
- Member
- Posts: 1036
- Joined: Thu Dec 21, 2006 3:03 am
- Location: Hobart, Australia
- Mastodon: https://aus.social/@jackscottau
- Matrix: @JackScottAU:matrix.org
- GitHub: https://github.com/JackScottAU
- Contact:
And GRUB is GPL, so good luck "copying" that source into something under a propreitary license.jal wrote:Since grub is OSS, it would be trivial to check its memory detection routines and copy those.Yayyak wrote:While the jury is still out, some consider that cheating. For those people, "ask GRUB" isn't the best answer.
JAL
You can learn the algoritm used, and after that you writing your own routines.Yayyak wrote:And GRUB is GPL, so good luck "copying" that source into something under a propreitary license.jal wrote:Since grub is OSS, it would be trivial to check its memory detection routines and copy those.Yayyak wrote:While the jury is still out, some consider that cheating. For those people, "ask GRUB" isn't the best answer.
JAL
You're on legally dodgy ground. You've used their algorithm, which you didn't know beforehand. That, IMHO although of course IANAL, is copying, so you must keep the licence.svdmeer wrote:You can learn the algoritm used, and after that you writing your own routines.Yayyak wrote:And GRUB is GPL, so good luck "copying" that source into something under a propreitary license.jal wrote: Since grub is OSS, it would be trivial to check its memory detection routines and copy those.
JAL
So if you saw that piece of Grub sourcecode accedentally, I can never program a piece of software for the same task without changing license?JamesM wrote:You're on legally dodgy ground. You've used their algorithm, which you didn't know beforehand. That, IMHO although of course IANAL, is copying, so you must keep the licence.svdmeer wrote:You can learn the algoritm used, and after that you writing your own routines.Yayyak wrote: And GRUB is GPL, so good luck "copying" that source into something under a propreitary license.
So If I put my memory-detection routine here, with the GPL attached on it, people who are scrolling past the license-information and read the code, will never be able to program something by themselves without the GPL?
As far as I know the right to "learn" (one of the basic rights of free software) is not restricted. You can use what you've learnt from a piece of free intellectual stuff for whatever you want, even write non-free software. But of course you can not take over the same lines of code, you have to re-develop the routines with the technical information you got by studying the source.
Unfortunately that's not wholly true.svdmeer wrote:So if you saw that piece of Grub sourcecode accedentally, I can never program a piece of software for the same task without changing license?JamesM wrote:You're on legally dodgy ground. You've used their algorithm, which you didn't know beforehand. That, IMHO although of course IANAL, is copying, so you must keep the licence.svdmeer wrote: You can learn the algoritm used, and after that you writing your own routines.
So If I put my memory-detection routine here, with the GPL attached on it, people who are scrolling past the license-information and read the code, will never be able to program something by themselves without the GPL?
As far as I know the right to "learn" (one of the basic rights of free software) is not restricted. You can use what you've learnt from a piece of free intellectual stuff for whatever you want, even write non-free software. But of course you can not take over the same lines of code, you have to re-develop the routines with the technical information you got by studying the source.
There is a reason that companies like my employer, when they need some code writing to do a task that some GPL software already does, will get someone to code it who has never ever seen the GPL'd code before.
If you copy someone's code, you must follow the licence under which that algorithm is released.
The problem of course comes because if you've looked at someone elses code, their implementation is likely going to influence yours. So what's the only fool proof way of proving that you didn't copy code? get someone who hasn't seen the original code to write your version.
"You have no rights". It's essentially true and is a very good base upon which to guess whether something is legal or not.
Enter clean-room reverse engineering. Have someone study the code, write down the algorithm used, and have someone who hasn't seen the code program the algorithm. This is the way early BIOS vendors reverse engineered the IBM BIOS.JamesM wrote:The problem of course comes because if you've looked at someone elses code, their implementation is likely going to influence yours. So what's the only fool proof way of proving that you didn't copy code? get someone who hasn't seen the original code to write your version.
As for the specific case of Grub, memory detection is so trivial (only using BIOS calls) that I doubt whether copying it line by line would violate the GPL in a defensable manner.
JAL
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
"Clean room" reverse engineering isn't required in many countries..
In Canada for instance, it's perfectly legal to reverse engineer something.. and re-implement your findings.
The BSD groups for instance, Developers can use a Linux driver as documentation, it's not pretty, but it's legal for them to do so, they're learning from the code, not copying it.
In Canada for instance, it's perfectly legal to reverse engineer something.. and re-implement your findings.
The BSD groups for instance, Developers can use a Linux driver as documentation, it's not pretty, but it's legal for them to do so, they're learning from the code, not copying it.
But with the same argument the written down algorithm has to be GPL.jal wrote:Enter clean-room reverse engineering. Have someone study the code, write down the algorithm used, and have someone who hasn't seen the code program the algorithm. This is the way early BIOS vendors reverse engineered the IBM BIOS.JamesM wrote:The problem of course comes because if you've looked at someone elses code, their implementation is likely going to influence yours. So what's the only fool proof way of proving that you didn't copy code? get someone who hasn't seen the original code to write your version.
As for the specific case of Grub, memory detection is so trivial (only using BIOS calls) that I doubt whether copying it line by line would violate the GPL in a defensable manner.
JAL
The idea with cleanroom reverse engineering is that the person who study the original does not reveal the algorithm, but just specification - in that case the information to the developer will be that the function has to determine the amount of available memory (back to square one)