Home arrow Forums
OSDEV Forums  


<< Start < Previous 1 2 Next > End >>
Mike359
User

Senior Osdever
Posts: 27
graphgraph
Karma: 1  
Something that cannot be described in a subject li - 2006/08/29 20:22
I'm one of those guys who built their OS as a "prototype" in another Operating system by not using any libraries.

I did that so most of my code was already built and I didn't waste away builds with testing stuff.

Well I finally got my code to switch over to protected mode and run the C/C++ code. Well nothing is getting printed. So I just compiled a real easy kernel with just some basic stuff:

Code:

  unsigned char *textaddress = (char *)0xB8000; void main(); void main() {     *textaddress++ = '!';     *textaddress++ = 7; }



Alright so a gray ! should be printed. Insteading nothing. And when main() is finished my second stage code just halts.

The people on the megatokyo board said the memory may not be mapped. Whats going on?
  | | The administrator has disabled public write access.
OSDEV
Community
Advertisement
   
gaf
User

Platinum Osdever
Posts: 153
graph
Karma: 10  
Re:Something that cannot be described in a subject li - 2006/08/30 10:14 (Click here to open the mega-tokyo thread about this topic)

The people on the megatokyo board said the memory may not be mapped. Whats going on?
Candy probably thought that you might be using paging. As long as you don't set the PG bit in cr0 paging is however disabled and you won't have to map anything.

Well I finally got my code to switch over to protected mode and run the C/C++ code. Well nothing is getting printed. So I just compiled a real easy kernel with just some basic stuff:
There seems to be some problem during the linking process. From what I can tell the global variable text-address has not been relocated to your kernel's base address:
Code:

    0:    fa                       cli        1:    e8 02 00 00 00           call   0x8    6:    fa                       cli    7:    f4                       hlt    8:    68 08 00 00 00           push   $0x8    d:    e8 ed ff fe ff           call   0xfffeffff      // stack ?   12:    52                       push   %edx   13:    a1 37 00 00 00           mov    0x37,%eax       // load text-address   18:    8d 50 01                 lea    0x1(%eax),%edx  // increase by one   1b:    89 15 37 00 00 00        mov    %edx,0x37       // store value   21:    c6 00 21                 movb   $0x21,(%eax)    // write !   24:    a1 37 00 00 00           mov    0x37,%eax       // load text-address   29:    8d 50 01                 lea    0x1(%eax),%edx  // increase by one   2c:    89 15 37 00 00 00        mov    %edx,0x37       // store value   32:    c6 00 07                 movb   $0x7,(%eax)     // write attribute   35:    eb fe                    jmp    0x35            // hang   37:    00 80 0b 00                 .dword 0x000B8000      // text-address data


As your kernel gets loaded to 0x10000 the address of your text-address variable should acctually be 0x10037 and not just 0x37. You'll have to tell Watcom/JLOC to link the binary to your base by either using some linker-script or by passing another parameter to the compiler.

Code:

 int main() {     charvidmem 0xB8000;     vidmem[0] = '!';     vidmem[1] = 7; }


You can use the above code to find out if the relocation address is really your problem. It uses a local variable to access video-memory and should thus work regardless of your base address.

Code:

 00000794842i[CPU0 ] |  CS:000800010|  000000000 000fffff 1 1 00000794842i[CPU0 ] |  DS:001000020|  000000000 000fffff 1 1 00000794842i[CPU0 ] |  SS:001000020|  000000000 000fffff 1 1 00000794842i[CPU0 ] |  ES:000000000|  000000000 0000ffff 0 0 00000794842i[CPU0 ] |  FS:000000000|  000000000 0000ffff 0 0 00000794842i[CPU0 ] |  GS:000000000|  000000000 0000ffff 0 0


Assigning a selector (0x10) to ES FS and GS would probably be a good idea. It's not the cause of your current problem, but you will eventually run into trouble as the C++ compiler must access these segments.

regards,
gaf
  | | The administrator has disabled public write access.
Mike359
User

Senior Osdever
Posts: 27
graphgraph
Karma: 1  
Re:Something that cannot be described in a subject - 2006/08/30 13:22 Yeah it printed the text alright. Argggh how can I command JLOC (or Watcom) to relocate the varibles?

This is my linker script:
Code:

  startup:      10000 10000 0           ,,,text,* code:         10000 startup.after startup.image+startup.length           ,,,_TEXT,* const:        10000 code.after code.image+code.length           ,,,_CONST,* data:         10000 const.after const.image+const.length           ,,,*,*

  | | The administrator has disabled public write access.
gaf
User

Platinum Osdever
Posts: 153
graph
Karma: 10  
Re:Something that cannot be described in a subject - 2006/08/30 14:46 Hmm, from what I could find out you probably should set the base field to zero rather than 0x10000: According to the documentation it actually seems to be the descriptor/segment base and not you kernel's base.

Code:

 section:  base  start  i_start  selector



base: base-address of your descriptor (flat-mode: 0)
start: offset in that descriptor (flat-mode: kernel base)

i_start: segment offset in the file
selector: probably only needed for 16bit code ?

Code:

 startup0 10000          ,,,text,* code:    0 startup.after startup.i_after          ,,,_TEXT,* const:   0 code.after code.i_after          ,,,_CONST,* data:    const.after const.i_after          ,,,*,*



Keep in mind that I'm actually more of an ld user: I won't guarantee for anything .

regards,
gaf
  | | The administrator has disabled public write access.
Mike359
User

Senior Osdever
Posts: 27
graphgraph
Karma: 1  
Re:Something that cannot be described in a subject - 2006/08/30 15:30 BRAWR!
It dosn't workbut i'll figure it out sooner or later.
I was going to use LD but it dosn't support the OBJS im using.
  | | The administrator has disabled public write access.
gaf
User

Platinum Osdever
Posts: 153
graph
Karma: 10  
Re:Something that cannot be described in a subject - 2006/08/30 16:35 [quot]It doesn't work but i'll figure it out sooner or later.
The funny thing is that the JLOC documentation actually even includes a linker-script for a boot-sector:
Code:

 ALL:    bootstrap.obj BOOT0 7C00 0    *


According to the docs this "tells JLOC that the assumed segment register points to 0, (and that) the section is actually loaded at 7C00 in memory". That's pretty much the same as you need for your kernel. All you have to do is making sure that the assembler stub gets linked first and that the kernel-base gets set to 0x10000:
Code:

 ALL: bootstrap.obj kernel.obj STARTUP0 10000 0          *,*,*,*,last.obj KERNEL:  0 STARTUP.after STARTUP.i_after          *


Maybe you could also post the hex-code of your updated C kernel ? As the new script will hopefully relocate the kernel as intended, it would probably be a good idea to make sure that there aren't any other problems.

regards,
gaf
  | | The administrator has disabled public write access.
Mike359
User

Senior Osdever
Posts: 27
graphgraph
Karma: 1  
Re:Something that cannot be described in a subject - 2006/08/30 17:26 What about the rest of my code and linker script?
  | | The administrator has disabled public write access.
Mike359
User

Senior Osdever
Posts: 27
graphgraph
Karma: 1  
Re:Something that cannot be described in a subject - 2006/08/30 17:57 That script didn't map all the segments. Heres the hex dump. Sorry im in a rush
Code:

  00000000  FA E8 C7 00 00 00 FA F4 52 68 01 07 00 00 E8 85    ...Rh.... 00000010  05 FF FF 83 C4 04 68 14 07 00 00 E8 78 05 FF FF    ..h....x. 00000020  83 C4 04 31 D2 B8 04 00 00 00 E8 0F 01 FF FF 68    .1Ҹ......h 00000030  67 07 00 00 E8 5F 05 FF FF 83 C4 04 31 D2 B8 07    g..._..1Ҹ. 00000040  00 00 00 E8 F6 00 FF FF 68 84 07 00 00 E8 46 05    ....h...F. 00000050  FF FF 83 C4 04 5A C3 80 3D E5 06 00 00 01 75 07    .=....u. 00000060  68 B8 07 00 00 EB 05 68 EC 07 00 00 E8 27 05 FF    h....h...'. 00000070  FF 83 C4 04 C3 C3 51 52 68 24 08 00 00 E8 16 05    .QRh$..... 00000080  FF FF 83 C4 04 31 C0 A0 ED 06 00 00 8B 14 85 42    .1 ....B 00000090  09 00 00 52 E8 FF 04 FF FF 83 C4 04 68 2E 08 00    ...R..h... 000000A0  00 E8 F2 04 FF FF 83 C4 04 31 C0 A0 EE 06 00 00    ...1 ... 000000B0  8B 0C 85 42 09 00 00 51 E8 DB 04 FF FF 83 C4 04    .B...Q.. 000000C0  5A 59 C3 E8 55 00 FF FF E9 0B 02 FF FF 53 51 52    ZYU...SQR 000000D0  56 57 F4 E8 EB FF FE FF E8 EA 00 FF FF E8 26 FF    VW.& 000000E0  FE FF E8 70 FF FE FF E8 89 FF FE FF E8 85 FF FE    p 000000F0  FF 5F 5E 5A 59 5B C3 66 85 C0 75 0C C7 05 2D 09    _^ZY[fu..-. 00000100  00 00 00 00 0B 00 EB 0A C7 05 2D 09 00 00 00 80    ........-.... 00000110  0B 00 A1 2D 09 00 00 A3 31 09 00 00 C3 B8 10 04    ..-...1...ø.. 00000120  00 00 8A 00 24 30 A2 29 09 00 00 3C 30 0F 95 C0    ...$0)...<0. 00000130  A2 E5 06 00 00 31 C0 A0 E5 06 00 00 EB B9 51 80    ...1 ...Q 00000140  3D E5 06 00 00 01 75 0D A2 E9 06 00 00 88 15 EA    =....u..... 00000150  06 00 00 EB 0F C6 05 E9 06 00 00 07 30 C9 88 0D    .........0Ɉ. 00000160  EA 06 00 00 A0 EA 06 00 00 C0 E0 04 A2 39 09 00    ... ....9.. 00000170  00 A0 E9 06 00 00 00 05 39 09 00 00 59 C3 52 66    . .....9...YRf 00000180  8B 15 37 09 00 00 42 66 89 15 37 09 00 00 31 C0    .7...Bf.7...1 00000190  66 89 D0 31 D2 E8 02 00 FF FF 5A C3 53 89 D3 31    f1..ZS1 000001A0  D2 66 89 C2 89 D0 C1 E0 02 01 D0 C1 E0 05 31 D2    f‰...1 000001B0  66 89 DA 01 D2 01 D0 8B 15 31 09 00 00 01 C2 89    f..Ћ.1....‰ 000001C0  15 2D 09 00 00 5B C3 52 A1 31 09 00 00 A3 2D 09    .-...[R1...-. 000001D0  00 00 66 81 3D 35 09 00 00 A0 0F 74 1A A1 2D 09    ..f=5... .t.-. 000001E0  00 00 8D 50 01 89 15 2D 09 00 00 C6 00 00 66 FF    ..P..-.....f 000001F0  05 35 09 00 00 EB DB 31 D2 31 C0 E8 9C FF FE FF    .5...11 00000200  31 D2 B8 07 00 00 00 E8 32 FF FE FF 5A C3 51 52    1Ҹ....2ZQR 00000210  88 C2 A1 2D 09 00 00 8D 48 01 89 0D 2D 09 00 00    ¡-...H..-... 00000220  88 10 A1 2D 09 00 00 8D 48 01 89 0D 2D 09 00 00    .-...H..-... 00000230  8A 15 39 09 00 00 88 10 5A 59 C3 B8 07 00 00 00    .9....ZYø.... 00000240  E8 C9 FF FE FF A1 2D 09 00 00 83 E8 02 A3 2D 09    -....-. 00000250  00 00 C3 53 51 52 56 57 E9 FF FF 00 00 5F 5E 5A    ..SQRVW.._^Z 00000260  59 5B C3 53 51 52 56 57 FA F4 5F 5E 5A 59 5B C3    Y[SQRVW_^ZY[ 00000270  53 51 52 56 57 55 89 E5 83 EC 04 89 45 FC 66 8B    SQRVWU.Ef 00000280  95 FC FF FF FF EC A2 3D 09 00 00 A0 3D 09 00 00    =... =... 00000290  89 EC 5D 5F 5E 5A 59 5B C3 53 51 56 57 55 89 E5    ]_^ZY[SQVWU 000002A0  83 EC 08 89 45 F8 89 55 FC 66 8B 95 F8 FF FF FF    .EUf 000002B0  66 8B 85 FC FF FF FF 66 EF 89 EC 5D 5F 5E 59 5B    ff]_^Y[ 000002C0  C3 52 31 D2 88 C2 C1 FA 04 88 15 ED 06 00 00 24    R1҈.....$ 000002D0  0F A2 EE 06 00 00 5A C3 52 BA 10 00 00 00 B8 70    ....ZR....p 000002E0  00 00 00 E8 B1 FF FE FF B8 71 00 00 00 E8 7E FF    ...q...~ 000002F0  FE FF A2 41 09 00 00 25 FF 00 00 00 E8 C0 FF FE    A...%... 00000300  FF 5A C3 51 52 88 C2 31 C9 88 C1 89 C8 E8 43 00    ZQR1ɈC. 00000310  FF FF 3C 01 75 0E 89 C8 E8 93 00 FF FF 3C 01 74    <.u..<.t 00000320  03 80 C2 20 88 D0 5A 59 C3 51 52 88 C2 31 C9 88    . ZYQR1Ɉ 00000330  C1 89 C8 E8 1D 00 FF FF 3C 01 75 0E 89 C8 E8 5F    ..<.u._ 00000340  00 FF FF 3C 01 74 03 80 EA 20 88 D0 5A 59 C3 3C    .<.t. ZY< 00000350  7F 0F 96 C0 C3 3C 41 72 07 3C 5A 77 03 B0 01 C3    .<Ar.<Zw.. 00000360  3C 61 72 04 3C 7A 76 F5 30 C0 C3 3C 20 0F 96 C0    <ar.<zv0< . 00000370  C3 3C 0B 72 0F 76 11 3C 0D 72 10 76 0B 3C 20 74    <.r.v.<.r.v.< t 00000380  07 30 C0 C3 3C 09 72 03 B0 01 C3 30 C0 C3 3C 09    .0<.r..0<. 00000390  0F 96 C0 C3 3C 30 72 07 3C 39 77 03 B0 01 C3 30    .<0r.<9w..0 000003A0  C0 C3 3C 41 72 07 3C 5A 77 03 B0 01 C3 30 C0 C3    <Ar.<Zw..0 000003B0  3C 61 72 07 3C 7A 77 03 B0 01 C3 30 C0 C3 2E 04    <ar.<zw..0.. 000003C0  00 00 3B 04 00 00 4A 04 00 00 56 04 00 00 62 04    ..;...J...V...b. 000003D0  00 00 6E 04 00 00 7A 04 00 00 86 04 00 00 92 04    ..n...z....... 000003E0  00 00 9E 04 00 00 53 51 52 56 57 89 C2 31 C9 89    .....SQRVW1ɉ 000003F0  0D F9 06 00 00 E8 E8 00 FF FF A3 F1 06 00 00 89    ........ 00000400  0D F5 06 00 00 8B 35 F1 06 00 00 85 F6 0F 84 C4    ....5.... 00000410  00 00 00 89 F0 8A 04 02 2C 30 3C 09 0F 87 88 00    .....,0<... 00000420  00 00 25 FF 00 00 00 FF 24 85 BE 03 00 00 31 DB    ..%...$...1 00000430  89 1D FD 06 00 00 E9 77 00 00 00 C7 05 FD 06 00    ....w...... 00000440  00 01 00 00 00 E9 68 00 00 00 C7 05 FD 06 00 00    .....h....... 00000450  02 00 00 00 EB 5C C7 05 FD 06 00 00 03 00 00 00    ............ 00000460  EB 50 C7 05 FD 06 00 00 04 00 00 00 EB 44 C7 05    P........D. 00000470  FD 06 00 00 05 00 00 00 EB 38 C7 05 FD 06 00 00    .......8.... 00000480  06 00 00 00 EB 2C C7 05 FD 06 00 00 07 00 00 00    ....,........ 00000490  EB 20 C7 05 FD 06 00 00 08 00 00 00 EB 14 C7 05     .......... 000004A0  FD 06 00 00 09 00 00 00 EB 08 31 FF 89 3D FD 06    ........1=. 000004B0  00 00 A1 F9 06 00 00 34 0A 0F AF 05 FD 06 00 00    .....4...... 000004C0  FF 0D F1 06 00 00 01 05 F5 06 00 00 FF 05 F9 06    ........... 000004D0  00 00 E9 2E FF FF FF A1 F5 06 00 00 5F 5E 5A 59    ......_^ZY 000004E0  5B C3 52 31 D2 89 15 5D 09 00 00 80 38 00 74 09    [R1҉.]...8.t. 000004F0  FF 05 5D 09 00 00 40 EB F2 A1 5D 09 00 00 5A C3    .]...@]...Z 00000500  53 51 56 57 89 C1 31 DB 89 1D 61 09 00 00 89 C8    SQVW1ۉ.a... 00000510  E8 CD FF FE FF 8B 35 61 09 00 00 39 F0 74 17 3A    5a...9t.: 00000520  11 75 07 89 F0 5F 5E 59 5B C3 41 8D 7E 01 89 3D    .u._^Y[A~.= 00000530  61 09 00 00 EB D8 B8 FF FF FF FF 5F 5E 59 5B C3    a...ظ_^Y[ 00000540  53 51 56 57 89 C1 89 D3 E8 95 FF FE FF 89 C2 89    SQVW‰ 00000550  D8 E8 8C FF FE FF 39 C2 74 07 30 C0 5F 5E 59 5B    9t.0_^Y[ 00000560  C3 31 C2 89 15 65 09 00 00 89 C8 E8 72 FF FE FF    1‰.e...r 00000570  8B 35 65 09 00 00 39 F0 74 17 89 F2 89 F0 8A 14    5e...9t.. 00000580  11 3A 14 03 75 D4 8D 7E 01 89 3D 65 09 00 00 EB    .:..uԍ~.=e... 00000590  D8 B0 01 5F 5E 59 5B C3 52 8B 54 24 08 8A 22 84    ذ._^Y[RT$." 000005A0  E4 0F 84 72 00 00 00 88 E0 80 FC 09 72 09 76 1A    .r....r.v. 000005B0  80 FC 0A 74 0E EB 56 80 FC 07 75 51 E8 7A FC FE    .t.V.uQz 000005C0  FF EB 53 E8 B6 FB FE FF EB 4C B8 20 00 00 00 E8    SL ... 000005D0  3A FC FE FF B8 20 00 00 00 E8 30 FC FE FF B8 20    : ...0  000005E0  00 00 00 E8 26 FC FE FF B8 20 00 00 00 E8 1C FC    ...& .... 000005F0  FE FF B8 20 00 00 00 E8 12 FC FE FF B8 20 00 00     .... .. 00000600  00 E8 08 FC FE FF B8 20 00 00 00 EB 04 31 C0 8A    .. ....1 00000610  02 E8 F8 FB FE FF 42 EB 84 5A C3 53 89 D3 31 D2    .BZS1 00000620  66 89 C2 31 C0 66 89 D8 E8 6F FB FE FF 68 8D 08    f1foh. 00000630  00 00 E8 61 FF FE FF 83 C4 04 5B C3 51 89 D1 31    ..a.[Q1 00000640  D2 66 89 C2 31 C0 66 89 C8 E8 4E FB FE FF 68 9B    f1fNh 00000650  08 00 00 E8 40 FF FE FF 83 C4 04 59 C3 51 52 89    ...@.YQR 00000660  C1 31 D2 31 C0 E8 32 FB FE FF 31 D2 B8 07 00 00    1121Ҹ... 00000670  00 E8 C8 FA FE FF 68 B2 08 00 00 E8 18 FF FE FF    .h.... 00000680  83 C4 04 31 D2 B8 04 00 00 00 E8 AF FA FE FF 68    .1Ҹ....h 00000690  C5 08 00 00 E8 FF FE FE FF 83 C4 04 31 D2 B8 07    ....1Ҹ. 000006A0  00 00 00 E8 96 FA FE FF 68 F7 08 00 00 E8 E6 FE    ...h... 000006B0  FE FF 83 C4 04 51 E8 DD FE FE FF 83 C4 04 BA 04    .Q.. 000006C0  00 00 00 31 C0 E8 51 FF FE FF BA 04 00 00 00 B8    ...1Q.... 000006D0  32 00 00 00 E8 63 FF FE FF 5A 59 C3 C3 85 C0 75    2...cZYÅu 000006E0  01 C3 31 C0 C3 00 00 00 00 00 00 00 00 00 00 00    .1........... 000006F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................ 00000700  00 43 6F 64 79 4F 53 20 57 6F 72 6B 73 74 61 74    .CodyOS Workstat 00000710  69 6F 6E 00 0A 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D    ion..----------- 00000720  2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D    ---------------- 00000730  2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D    ---------------- 00000740  2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D    ---------------- 00000750  2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D    ---------------- 00000760  2D 2D 2D 2D 2D 0A 00 2A 2A 2A 2A 20 50 52 45 2D    -----..**** PRE- 00000770  41 4C 50 48 41 20 56 45 52 53 49 4F 4E 20 2A 2A    ALPHA VERSION ** 00000780  2A 2A 0A 00 48 61 72 64 77 61 72 65 3A 20 41 74    **..Hardware: At 00000790  74 65 6D 70 74 69 6E 67 20 74 6F 20 64 65 74 65    tempting to dete 000007A0  63 74 20 61 76 61 69 62 6C 65 20 68 61 72 64 77    ct avaible hardw 000007B0  61 72 65 2E 2E 2E 0A 00 56 69 64 65 6F 3A 20 41    are.....Video: A 000007C0  20 63 6F 6C 6F 75 72 20 64 69 73 70 6C 61 79 20     colour display  000007D0  61 64 61 70 74 65 72 20 68 61 73 20 62 65 65 6E    adapter has been 000007E0  20 64 65 74 65 63 74 65 64 2E 0A 00 56 69 64 65     detected...Vide 000007F0  6F 3A 20 41 20 6D 6F 6E 6F 63 68 72 6F 6D 65 20    o: A monochrome  00000800  64 69 73 70 6C 61 79 20 61 64 61 70 74 65 72 20    display adapter  00000810  68 61 73 20 62 65 65 6E 20 64 65 74 65 63 74 65    has been detecte 00000820  64 2E 0A 00 46 6C 6F 70 70 79 31 3A 20 00 0A 46    d...Floppy1: ..F 00000830  6C 6F 70 70 79 32 3A 20 00 4E 6F 74 20 77 6F 72    loppy2: .Not wor 00000840  6B 69 6E 67 20 6F 72 20 61 74 74 61 63 68 65 64    king or attached 00000850  00 33 36 30 4B 42 20 35 2E 31 34 00 31 2E 32 4D    .360KB 5.14.1.2M 00000860  42 20 35 2E 31 34 00 37 32 30 4B 42 20 33 2E 31    B 5.14.720KB 3.1 00000870  32 00 31 2E 34 34 4D 42 20 33 2E 31 32 00 32 2E    2.1.44MB 3.12.2. 00000880  38 38 4D 42 20 33 2E 31 32 00 00 00 00 4D 65 6D    88MB 3.12....Mem 00000890  6F 72 79 20 64 75 6D 70 3A 0A 00 53 79 73 74 65    ory dump:..Syste 000008A0  6D 20 72 65 67 69 73 74 65 72 20 64 75 6D 70 3A    m register dump: 000008B0  0A 00 43 6F 64 79 4F 53 20 57 6F 72 6B 73 74 61    ..CodyOS Worksta 000008C0  74 69 6F 6E 00 0A 53 48 4F 57 53 54 4F 50 50 45    tion..SHOWSTOPPE 000008D0  52 3A 20 41 6E 20 75 6E 72 65 63 6F 76 65 72 61    R: An unrecovera 000008E0  62 6C 65 20 66 61 75 6C 74 20 68 61 73 20 6F 63    ble fault has oc 000008F0  63 75 72 65 64 0A 00 2D 2D 2D 2D 2D 2D 2D 2D 2D    cured..--------- 00000900  2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D    ---------------- 00000910  2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D    ---------------- 00000920  2D 2D 2D 2D 2D 2D 2D 0A 00 00 00 00 00 00 00 00    -------......... 00000930  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................ 00000940  00 00 39 08 00 00 51 08 00 00 5C 08 00 00 67 08    ..9...Q......g. 00000950  00 00 72 08 00 00 7E 08 00 00 00 00 00 00 00 00    ..r...~......... 00000960  00 00 00 00 00 00 00 00 00                         .........       



Post edited by: Mike359, at: 2006/08/30 19:59
  | | The administrator has disabled public write access.
gaf
User

Platinum Osdever
Posts: 153
graph
Karma: 10  
Re:Something that cannot be described in a subject - 2006/09/01 11:20 What about the rest of my code and linker script?
As long as you're in 32bit pmode the rest of the code actually shouldnt make a difference.

Code:

 startup (assembler): 00:    fa                       cli     01:    e8 c7 00 00 00           call   0xcd 06:    fa                       cli 07:    f4                       hlt  kernel::main() cd:    53                       push   %ebx ce:    51                       push   %ecx cf:    52                       push   %edx d0:    56                       push   %esi d1:    57                       push   %edi d2:    f4                       hlt     d3:    e8 eb ff fe ff           call   0xffff00c3 d8:    e8 ea 00 ff ff           call   0xffff01c7 dd:    e8 26 ff fe ff           call   0xffff0008 e2:    e8 70 ff fe ff           call   0xffff0057 e7:    e8 89 ff fe ff           call   0xffff0075 ec:    e8 85 ff fe ff           call   0xffff0076 f1:    5f                       pop    %edi f2:    5e                       pop    %esi f3:    5a                       pop    %edx f4:    59                       pop    %ecx f5:    5b                       pop    %ebx f6:    c3                       ret



What really surpised me is that the main() calls in your assembler start-up code works perfectly fine, while all calls in the kernel itself are still broken. On the other hand jumps seem to work in all source-files .

Let's have a look at the call at address 0xd3 in the hex dump (e8 eb ff fe ff). The first byte is the opcode of the relative call, while the other 4 bytes define the value to be added to EIP (0xfffeff). As it's an ordinary signed 32bit number, we can get the absolute value by doing a two's complement:

0xfffeffeb -invert-> 0x10014 -add-> 0x10013

The resulting value (-0x10013) gets now added to the address following the call instruction (0x100d8), so that we eventually end up with 0xc5 and not 0x100C5 as intended.

In my opinion this behaviour is really weird: The linker now seems to have understood that it's currently at a location greater than 0x10000 - otherwise the calls wouldn't be broken. On the other hand it however doesn't seem to know that all the other procedures, aswell as the data-section, are also located at 0x10000+ - thus global variables still don't get accessed correctly.

It's definitly a problem with the linker, and I'm afraid that I know too little about JLOC to be much of a help here. Maybe it would be a good idea to reactivate your mega-tokyo thread: If you're lucky there should be some other JLOC user on that board..

regards,
gaf
  | | The administrator has disabled public write access.
Mike359
User

Senior Osdever
Posts: 27
graphgraph
Karma: 1  
Re:Something that cannot be described in a subject - 2006/09/01 12:48 Ill post a topic in the old thread. I also have a problem with Watcom. It inserts function calls like that when I call functions which crash the kernel. Gaf do you have MSN? Add me Mike359@Gmail.Com

Post edited by: Mike359, at: 2006/09/01 12:58
  | | The administrator has disabled public write access.
<< Start < Previous 1 2 Next > End >>

A WebArticles site. Sponsored by Evoleto. Motorola V525 / Business Directory / Delaware Incorporation / Home Made Bazaar