Write to 0xB8000 does't work

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
Steve the Pirate
Member
Member
Posts: 152
Joined: Fri Dec 15, 2006 7:01 am
Location: Brisbane, Australia
Contact:

Re: Write to 0xB8000 does't work

Post by Steve the Pirate »

gzaloprgm wrote:However, if you use GRUB, remember it may require your OS to be GPL'd or similar.
I don't think that is true. Apart from one little structure, you don't need any other code to use Grub, so I doubt anyone would care about what license you're using...
My Site | My Blog
Symmetry - My operating system.
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Re: Write to 0xB8000 does't work

Post by gzaloprgm »

Steve the Pirate wrote:
gzaloprgm wrote:However, if you use GRUB, remember it may require your OS to be GPL'd or similar.
I don't think that is true. Apart from one little structure, you don't need any other code to use Grub, so I doubt anyone would care about what license you're using...
Well, but will you include a iso / img file without a bootloader :shock: and wait for the user to boot it with grub ?

:oops: I think you are misunderstanding GPL
The GPL is the most popular and well-known example of the type of strong copyleft license that requires derived works to be available under the same copyleft.
and
You have a GPL'ed program that I'd like to link with my code to build a proprietary program. Does the fact that I link with your program mean I have to GPL my program?
Yes.
So it's not a solution if you are making a closed-source OS

Cheers,
gzaloprgm
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Re: Write to 0xB8000 does't work

Post by ucosty »

gzaloprgm wrote: :oops: I think you are misunderstanding GPL
The GPL is the most popular and well-known example of the type of strong copyleft license that requires derived works to be available under the same copyleft.
and
You have a GPL'ed program that I'd like to link with my code to build a proprietary program. Does the fact that I link with your program mean I have to GPL my program?
Yes.
So it's not a solution if you are making a closed-source OS
Unless your OS code base is actually based on Grub source code it is not a derived work.

Linking has a very specific meaning. It has nothing to do with 'including alongside'. Unless you compile your code base against Grub (similar to a library) it is not linked.

If this were not the case you'd never be able anything *but* GPL [and compatible] software on Linux.
The cake is a lie | rackbits.com
User avatar
Steve the Pirate
Member
Member
Posts: 152
Joined: Fri Dec 15, 2006 7:01 am
Location: Brisbane, Australia
Contact:

Re: Write to 0xB8000 does't work

Post by Steve the Pirate »

ucosty wrote:Unless your OS code base is actually based on Grub source code it is not a derived work.

Linking has a very specific meaning. It has nothing to do with 'including alongside'. Unless you compile your code base against Grub (similar to a library) it is not linked.

If this were not the case you'd never be able anything *but* GPL [and compatible] software on Linux.
Precisely. Even if you distribute the GRUB binaries on you OS's disk images, you can still use any licence you want for your OS, and even keep it closed source if you really want to (but that's a really stupid idea for a hobby OS).

The only implications of using GRUB is that if sombody requests it, you will probably need to put a link (or host a copy of) the GRUB source code on your project's web page - although if you haven't modified it, you can probably just point them to the GRUB website.
My Site | My Blog
Symmetry - My operating system.
spiner900
Member
Member
Posts: 26
Joined: Mon Mar 09, 2009 10:47 am

Re: Write to 0xB8000 does't work

Post by spiner900 »

No body found a solution for my problem ?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Write to 0xB8000 does't work

Post by Solar »

Erm... unless I am mistaken, we were at the point where your bootloader only loads the first 512 bytes of your kernel. Did you fix that?

You might also use objdump to make sure .text and .data are indeed the only sections from the object files that you need in your kernel binary. I'd bet money on there being a .rodata section that's not being included in the binary...
Every good solution is obvious once you've found it.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Write to 0xB8000 does't work

Post by Troy Martin »

Or there's always another idea....

Bare bones
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
spiner900
Member
Member
Posts: 26
Joined: Mon Mar 09, 2009 10:47 am

Re: Write to 0xB8000 does't work

Post by spiner900 »

Ok I have fix my bootSecteur to load 16 sector (8 kb) and this is mais kernel.o dump but what I have to do with that ?

Code: Select all

e format elf64-x86-64

Disassembly of section .text:

0000000000000000 <kernel_main>:
   0:	55                   	push   %rbp
   1:	48 89 e5             	mov    %rsp,%rbp
   4:	48 8b 05 00 00 00 00 	mov    0x0(%rip),%rax        # b <kernel_main+0xb>
   b:	c6 00 41             	movb   $0x41,(%rax)
   e:	48 83 c0 01          	add    $0x1,%rax
  12:	48 89 05 00 00 00 00 	mov    %rax,0x0(%rip)        # 19 <kernel_main+0x19>
  19:	48 8b 05 00 00 00 00 	mov    0x0(%rip),%rax        # 20 <kernel_main+0x20>
  20:	c6 00 02             	movb   $0x2,(%rax)
  23:	48 83 c0 01          	add    $0x1,%rax
  27:	48 89 05 00 00 00 00 	mov    %rax,0x0(%rip)        # 2e <kernel_main+0x2e>
  2e:	48 8b 05 00 00 00 00 	mov    0x0(%rip),%rax        # 35 <kernel_main+0x35>
  35:	c6 00 41             	movb   $0x41,(%rax)
  38:	48 83 c0 01          	add    $0x1,%rax
  3c:	48 89 05 00 00 00 00 	mov    %rax,0x0(%rip)        # 43 <kernel_main+0x43>
  43:	48 8b 05 00 00 00 00 	mov    0x0(%rip),%rax        # 4a <kernel_main+0x4a>
  4a:	c6 00 07             	movb   $0x7,(%rax)
  4d:	48 83 c0 01          	add    $0x1,%rax
  51:	48 89 05 00 00 00 00 	mov    %rax,0x0(%rip)        # 58 <kernel_main+0x58>
  58:	48 8b 05 00 00 00 00 	mov    0x0(%rip),%rax        # 5f <kernel_main+0x5f>
  5f:	c6 00 41             	movb   $0x41,(%rax)
  62:	48 83 c0 01          	add    $0x1,%rax
  66:	48 89 05 00 00 00 00 	mov    %rax,0x0(%rip)        # 6d <kernel_main+0x6d>
  6d:	48 8b 05 00 00 00 00 	mov    0x0(%rip),%rax        # 74 <kernel_main+0x74>
  74:	c6 00 02             	movb   $0x2,(%rax)
  77:	48 83 c0 01          	add    $0x1,%rax
  7b:	48 89 05 00 00 00 00 	mov    %rax,0x0(%rip)        # 82 <kernel_main+0x82>
  82:	eb fe                	jmp    82 <kernel_main+0x82>
Disassembly of section .data:

0000000000000000 <p>:
   0:	00 80 0b 00 00 00    	add    %al,0xb(%rax)
	...
Disassembly of section .eh_frame:

0000000000000000 <.eh_frame>:
   0:	14 00                	adc    $0x0,%al
   2:	00 00                	add    %al,(%rax)
   4:	00 00                	add    %al,(%rax)
   6:	00 00                	add    %al,(%rax)
   8:	01 7a 52             	add    %edi,0x52(%rdx)
   b:	00 01                	add    %al,(%rcx)
   d:	78 10                	js     1f <.eh_frame+0x1f>
   f:	01 03                	add    %eax,(%rbx)
  11:	0c 07                	or     $0x7,%al
  13:	08 90 01 00 00 24    	or     %dl,0x24000001(%rax)
  19:	00 00                	add    %al,(%rax)
  1b:	00 1c 00             	add    %bl,(%rax,%rax,1)
  1e:	00 00                	add    %al,(%rax)
  20:	00 00                	add    %al,(%rax)
  22:	00 00                	add    %al,(%rax)
  24:	84 00                	test   %al,(%rax)
  26:	00 00                	add    %al,(%rax)
  28:	00 04 01             	add    %al,(%rcx,%rax,1)
  2b:	00 00                	add    %al,(%rax)
  2d:	00 0e                	add    %cl,(%rsi)
  2f:	10 86 02 04 03 00    	adc    %al,0x30402(%rsi)
  35:	00 00                	add    %al,(%rax)
  37:	0d 06 00 00 00       	or     $0x6,%eax
  3c:	00 00                	add    %al,(%rax)
	...
Disassembly of section .comment:

0000000000000000 <.comment>:
   0:	00 47 43             	add    %al,0x43(%rdi)
   3:	43 3a 20             	rex.XB cmp    (%r8),%spl
   6:	28 47 4e             	sub    %al,0x4e(%rdi)
   9:	55                   	push   %rbp
   a:	29 20                	sub    %esp,(%rax)
   c:	34 2e                	xor    $0x2e,%al
   e:	32 2e                	xor    (%rsi),%ch
  10:	34 20                	xor    $0x20,%al
  12:	28 55 62             	sub    %dl,0x62(%rbp)
  15:	75 6e                	jne    85 <kernel_main+0x85>
  17:	74 75                	je     8e <kernel_main+0x8e>
  19:	20 34 2e             	and    %dh,(%rsi,%rbp,1)
  1c:	32 2e                	xor    (%rsi),%ch
  1e:	34 2d                	xor    $0x2d,%al
  20:	31 75 62             	xor    %esi,0x62(%rbp)
  23:	75 6e                	jne    93 <kernel_main+0x93>
  25:	74 75                	je     9c <kernel_main+0x9c>
  27:	33 29                	xor    (%rcx),%ebp
	...

User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Write to 0xB8000 does't work

Post by Troy Martin »

I don't see a .data and a .rodata or .rdata section in the dump...
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
spiner900
Member
Member
Posts: 26
Joined: Mon Mar 09, 2009 10:47 am

Re: Write to 0xB8000 does't work

Post by spiner900 »

the .data is just afterthe .text
and for the .rodata how can I get it ?

Code: Select all

Disassembly of section .data:

0000000000000000 <p>:
   0:   00 80 0b 00 00 00       add    %al,0xb(%rax)
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Re: Write to 0xB8000 does't work

Post by gzaloprgm »

Are you in a 64-bit linux distribution? If so, are you linking to a 32 bit plain binary file?

I you aren't, try adding "-m 32" to the gcc compile command.

Cheers,
Gzaloprgm
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
spiner900
Member
Member
Posts: 26
Joined: Mon Mar 09, 2009 10:47 am

Re: Write to 0xB8000 does't work

Post by spiner900 »

Yes I'm on Ubuntu 64 but that does't work. I got this

ld: unrecognised emulation mode: 32
Supported emulations: elf_x86_64 elf_i386 i386linux

and i'm want a real binary
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Write to 0xB8000 does't work

Post by Troy Martin »

gzaloprgm wrote:try adding "-m 32" to the gcc compile command.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
spiner900
Member
Member
Posts: 26
Joined: Mon Mar 09, 2009 10:47 am

Re: Write to 0xB8000 does't work

Post by spiner900 »

Ok that work thank you very much ! The problem that i got was I link with LD and not GCC. look the solution.

CFLAGS= -m32 -c -I $(INC_PATH) -ffreestanding -nostdinc -nostdlib -Wall -Werror -fno-stack-protector
LDFLAGS= -m elf_i386 -T linker.ld

I have a two other question. In many ld scipt we find ALIGN(4096) ... I know that is 64 kb but why we have to put that ???
And i'm new user under Linux ..... the elf format it is the same think of the PE format under Windows ??
JohnnyTheDon
Member
Member
Posts: 524
Joined: Sun Nov 09, 2008 2:55 am
Location: Pennsylvania, USA

Re: Write to 0xB8000 does't work

Post by JohnnyTheDon »

4096 is NOT 64kb, its 4kb. You need that alignment for paging because pages a 4kb in size. You should be able to get away without it, but using at least ALIGN(16) is a good idea to speed up memory accesses.

And no, elf is not the same as PE. They are two completely different formats. You should probably use ELF for osdev because its easier to parse yourself and grub loads it easily.
Post Reply