Memory Allocation

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.
User avatar
JackScott
Member
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:

Post by JackScott »

While the jury is still out, some consider that cheating. For those people, "ask GRUB" isn't the best answer.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Yayyak wrote:While the jury is still out, some consider that cheating. For those people, "ask GRUB" isn't the best answer.
Since grub is OSS, it would be trivial to check its memory detection routines and copy those.


JAL
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

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
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

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.
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.


JAL
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

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.
Last edited by svdmeer on Wed May 14, 2008 5:57 am, edited 1 time in total.
User avatar
JackScott
Member
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:

Post by JackScott »

jal wrote:
Yayyak wrote:While the jury is still out, some consider that cheating. For those people, "ask GRUB" isn't the best answer.
Since grub is OSS, it would be trivial to check its memory detection routines and copy those.

JAL
And GRUB is GPL, so good luck "copying" that source into something under a propreitary license.
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

Yayyak wrote:
jal wrote:
Yayyak wrote:While the jury is still out, some consider that cheating. For those people, "ask GRUB" isn't the best answer.
Since grub is OSS, it would be trivial to check its memory detection routines and copy those.

JAL
And GRUB is GPL, so good luck "copying" that source into something under a propreitary license.
You can learn the algoritm used, and after that you writing your own routines.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

svdmeer wrote:
Yayyak wrote:
jal wrote: Since grub is OSS, it would be trivial to check its memory detection routines and copy those.

JAL
And GRUB is GPL, so good luck "copying" that source into something under a propreitary license.
You can learn the algoritm used, and after that you writing your own routines.
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
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

JamesM wrote:
svdmeer wrote:
Yayyak wrote: And GRUB is GPL, so good luck "copying" that source into something under a propreitary license.
You can learn the algoritm used, and after that you writing your own routines.
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.
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?

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.
User avatar
CmpXchg
Member
Member
Posts: 61
Joined: Mon Apr 28, 2008 12:14 pm
Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime

Post by CmpXchg »

What's the point in OSS if I can't use it to gather ideas?
Besides, you can use some other programming language to make the routines that do the same.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

svdmeer wrote:
JamesM wrote:
svdmeer wrote: You can learn the algoritm used, and after that you writing your own routines.
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.
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?

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.

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.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

AFAIK, the UK has significantly stronger copyright laws in this area than the US does, however.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

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.
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.

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
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

"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. ;)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
skyking
Member
Member
Posts: 174
Joined: Sun Jan 06, 2008 8:41 am

Post by skyking »

jal wrote:
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.
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.

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
But with the same argument the written down algorithm has to be GPL.

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)
Post Reply