Questo sito utilizza cookies, anche di terze parti, per mostrare pubblicità e servizi in linea con il tuo account. Leggi l'informativa sui cookies.
Username: Password: oppure
Altri Linguaggi - [Risolto][OSDEV] Mac e Assembly...che rompicapo!
Forum - Altri Linguaggi - [Risolto][OSDEV] Mac e Assembly...che rompicapo!

Avatar
LittleHacker (Member)
Guru


Messaggi: 1033
Iscritto: 28/04/2009

Segnala al moderatore
Postato alle 6:17
Venerdì, 12/04/2013
Salve a tutti, sto da poco provando a compilare il mio MicroOS su piattaforma Mac OSX 10.8.3, ho installato tutto il necessario (nasm, gcc, g++, ld) ma ho un problema per quanto rigurda il linking del codice Assembler!

Ho questo codide:
Codice sorgente - presumibilmente Php

  1. global loader
  2. global _gdt_flush       ; expose gdt reload routine
  3. global _idt_load        ; loads the IDT
  4.  
  5. global _isr0
  6. global _isr1
  7. global _isr2
  8. global _isr3
  9. global _isr4
  10. global _isr5
  11. global _isr6
  12. global _isr7
  13. global _isr8
  14. global _isr9
  15. global _isr10
  16. global _isr11
  17. global _isr12
  18. global _isr13
  19. global _isr14
  20. global _isr15
  21. global _isr16
  22. global _isr17
  23. global _isr18
  24. global _isr19
  25. global _isr20
  26. global _isr21
  27. global _isr22
  28. global _isr23
  29. global _isr24
  30. global _isr25
  31. global _isr26
  32. global _isr27
  33. global _isr28
  34. global _isr29
  35. global _isr30
  36. global _isr31
  37.  
  38. global _irq0
  39. global _irq1
  40. global _irq2
  41. global _irq3
  42. global _irq4
  43. global _irq5
  44. global _irq6
  45. global _irq7
  46. global _irq8
  47. global _irq9
  48. global _irq10
  49. global _irq11
  50. global _irq12
  51. global _irq13
  52. global _irq14
  53. global _irq15
  54.  
  55.  
  56. extern kernel           ; our Kernel pointer
  57. extern gp               ; our GDT pointer is exposed elsewhere also
  58. extern idtp             ; our IDT pointer
  59.  
  60. MODULEALIGN equ 1<<0
  61. MEMINFO equ 1<<1
  62. FLAGS equ MODULEALIGN | MEMINFO
  63. MAGIC equ 0x1BADB002
  64. CHECKSUM equ -(MAGIC + FLAGS)
  65.  
  66. section .text
  67. align 4
  68. MultiBootHeader:
  69. dd MAGIC
  70. dd FLAGS
  71. dd CHECKSUM
  72.  
  73. STACKSIZE equ 0x4000
  74.  
  75. loader:
  76. mov esp, stack+STACKSIZE
  77. push eax
  78. push ebx
  79.  
  80. call kernel                             ; Call kernel main
  81.  
  82. cli
  83.  
  84. hang:
  85. hlt
  86. jmp hang
  87.  
  88. _gdt_flush:                             ; This routine will reload the segment registers when called
  89.     lgdt [gp]                           ; This line loads our custom GDT
  90.     mov ax, 0x10
  91.     mov ds, ax
  92.     mov es, ax
  93.     mov fs, ax
  94.     mov gs, ax
  95.     mov ss, ax
  96.     ret
  97.  
  98. _idt_load:
  99.    lidt [idtp]
  100.    ret
  101.  
  102. ;  0: Divide By Zero Exception
  103. _isr0:
  104.     cli
  105.     push byte 0
  106.     push byte 0
  107.     jmp isr_common_stub
  108.  
  109. ;  1: Debug Exception
  110. _isr1:
  111.     cli
  112.     push byte 0
  113.     push byte 1
  114.     jmp isr_common_stub
  115.  
  116. ;  2: Non Maskable Interrupt Exception
  117. _isr2:
  118.     cli
  119.     push byte 0
  120.     push byte 2
  121.     jmp isr_common_stub
  122.  
  123. ;  3: Int 3 Exception
  124. _isr3:
  125.     cli
  126.     push byte 0
  127.     push byte 3
  128.     jmp isr_common_stub
  129.  
  130. ;  4: INTO Exception
  131. _isr4:
  132.     cli
  133.     push byte 0
  134.     push byte 4
  135.     jmp isr_common_stub
  136.  
  137. ;  5: Out of Bounds Exception
  138. _isr5:
  139.     cli
  140.     push byte 0
  141.     push byte 5
  142.     jmp isr_common_stub
  143.  
  144. ;  6: Invalid Opcode Exception
  145. _isr6:
  146.     cli
  147.     push byte 0
  148.     push byte 6
  149.     jmp isr_common_stub
  150.  
  151. ;  7: Coprocessor Not Available Exception
  152. _isr7:
  153.     cli
  154.     push byte 0
  155.     push byte 7
  156.     jmp isr_common_stub
  157.  
  158. ;  8: Double Fault Exception (With Error Code!)
  159. _isr8:
  160.     cli
  161.     push byte 8
  162.     jmp isr_common_stub
  163.  
  164. ;  9: Coprocessor Segment Overrun Exception
  165. _isr9:
  166.     cli
  167.     push byte 0
  168.     push byte 9
  169.     jmp isr_common_stub
  170.  
  171. ; 10: Bad TSS Exception (With Error Code!)
  172. _isr10:
  173.     cli
  174.     push byte 10
  175.     jmp isr_common_stub
  176.  
  177. ; 11: Segment Not Present Exception (With Error Code!)
  178. _isr11:
  179.     cli
  180.     push byte 11
  181.     jmp isr_common_stub
  182.  
  183. ; 12: Stack Fault Exception (With Error Code!)
  184. _isr12:
  185.     cli
  186.     push byte 12
  187.     jmp isr_common_stub
  188.  
  189. ; 13: General Protection Fault Exception (With Error Code!)
  190. _isr13:
  191.     cli
  192.     push byte 13
  193.     jmp isr_common_stub
  194.  
  195. ; 14: Page Fault Exception (With Error Code!)
  196. _isr14:
  197.     cli
  198.     push byte 14
  199.     jmp isr_common_stub
  200.  
  201. ; 15: Reserved Exception
  202. _isr15:
  203.     cli
  204.     push byte 0
  205.     push byte 15
  206.     jmp isr_common_stub
  207.  
  208. ; 16: Floating Point Exception
  209. _isr16:
  210.     cli
  211.     push byte 0
  212.     push byte 16
  213.     jmp isr_common_stub
  214.  
  215. ; 17: Alignment Check Exception
  216. _isr17:
  217.     cli
  218.     push byte 0
  219.     push byte 17
  220.     jmp isr_common_stub
  221.  
  222. ; 18: Machine Check Exception
  223. _isr18:
  224.     cli
  225.     push byte 0
  226.     push byte 18
  227.     jmp isr_common_stub
  228.  
  229. ; 19: Reserved
  230. _isr19:
  231.     cli
  232.     push byte 0
  233.     push byte 19
  234.     jmp isr_common_stub
  235.  
  236. ; 20: Reserved
  237. _isr20:
  238.     cli
  239.     push byte 0
  240.     push byte 20
  241.     jmp isr_common_stub
  242.  
  243. ; 21: Reserved
  244. _isr21:
  245.     cli
  246.     push byte 0
  247.     push byte 21
  248.     jmp isr_common_stub
  249.  
  250. ; 22: Reserved
  251. _isr22:
  252.     cli
  253.     push byte 0
  254.     push byte 22
  255.     jmp isr_common_stub
  256.  
  257. ; 23: Reserved
  258. _isr23:
  259.     cli
  260.     push byte 0
  261.     push byte 23
  262.     jmp isr_common_stub
  263.  
  264. ; 24: Reserved
  265. _isr24:
  266.     cli
  267.     push byte 0
  268.     push byte 24
  269.     jmp isr_common_stub
  270.  
  271. ; 25: Reserved
  272. _isr25:
  273.     cli
  274.     push byte 0
  275.     push byte 25
  276.     jmp isr_common_stub
  277.  
  278. ; 26: Reserved
  279. _isr26:
  280.     cli
  281.     push byte 0
  282.     push byte 26
  283.     jmp isr_common_stub
  284.  
  285. ; 27: Reserved
  286. _isr27:
  287.     cli
  288.     push byte 0
  289.     push byte 27
  290.     jmp isr_common_stub
  291.  
  292. ; 28: Reserved
  293. _isr28:
  294.     cli
  295.     push byte 0
  296.     push byte 28
  297.     jmp isr_common_stub
  298.  
  299. ; 29: Reserved
  300. _isr29:
  301.     cli
  302.     push byte 0
  303.     push byte 29
  304.     jmp isr_common_stub
  305.  
  306. ; 30: Reserved
  307. _isr30:
  308.     cli
  309.     push byte 0
  310.     push byte 30
  311.     jmp isr_common_stub
  312.  
  313. ; 31: Reserved
  314. _isr31:
  315.     cli
  316.     push byte 0
  317.     push byte 31
  318.     jmp isr_common_stub
  319.  
  320.  
  321. ; We call a C function in here. We need to let the assembler know
  322. ; that '_fault_handler' exists in another file
  323. extern _fault_handler
  324.  
  325. ; This is our common ISR stub. It saves the processor state, sets
  326. ; up for kernel mode segments, calls the C-level fault handler,
  327. ; and finally restores the stack frame.
  328. isr_common_stub:
  329.     pusha
  330.     push ds
  331.     push es
  332.     push fs
  333.     push gs
  334.     mov ax, 0x10
  335.     mov ds, ax
  336.     mov es, ax
  337.     mov fs, ax
  338.     mov gs, ax
  339.     mov eax, esp
  340.     push eax
  341.     mov eax, _fault_handler
  342.     call eax
  343.     pop eax
  344.     pop gs
  345.     pop fs
  346.     pop es
  347.     pop ds
  348.     popa
  349.     add esp, 8
  350.     iret
  351.  
  352. ; 32: IRQ0
  353. _irq0:
  354.     cli
  355.     push byte 0
  356.     push byte 32
  357.     jmp irq_common_stub
  358.  
  359. ; 33: IRQ1
  360. _irq1:
  361.     cli
  362.     push byte 0
  363.     push byte 33
  364.     jmp irq_common_stub
  365.  
  366. ; 34: IRQ2
  367. _irq2:
  368.     cli
  369.     push byte 0
  370.     push byte 34
  371.     jmp irq_common_stub
  372.  
  373. ; 35: IRQ3
  374. _irq3:
  375.     cli
  376.     push byte 0
  377.     push byte 35
  378.     jmp irq_common_stub
  379.  
  380. ; 36: IRQ4
  381. _irq4:
  382.     cli
  383.     push byte 0
  384.     push byte 36
  385.     jmp irq_common_stub
  386.  
  387. ; 37: IRQ5
  388. _irq5:
  389.     cli
  390.     push byte 0
  391.     push byte 37
  392.     jmp irq_common_stub
  393.  
  394. ; 38: IRQ6
  395. _irq6:
  396.     cli
  397.     push byte 0
  398.     push byte 38
  399.     jmp irq_common_stub
  400.  
  401. ; 39: IRQ7
  402. _irq7:
  403.     cli
  404.     push byte 0
  405.     push byte 39
  406.     jmp irq_common_stub
  407.  
  408. ; 40: IRQ8
  409. _irq8:
  410.     cli
  411.     push byte 0
  412.     push byte 40
  413.     jmp irq_common_stub
  414.  
  415. ; 41: IRQ9
  416. _irq9:
  417.     cli
  418.     push byte 0
  419.     push byte 41
  420.     jmp irq_common_stub
  421.  
  422. ; 42: IRQ10
  423. _irq10:
  424.     cli
  425.     push byte 0
  426.     push byte 42
  427.     jmp irq_common_stub
  428.  
  429. ; 43: IRQ11
  430. _irq11:
  431.     cli
  432.     push byte 0
  433.     push byte 43
  434.     jmp irq_common_stub
  435.  
  436. ; 44: IRQ12
  437. _irq12:
  438.     cli
  439.     push byte 0
  440.     push byte 44
  441.     jmp irq_common_stub
  442.  
  443. ; 45: IRQ13
  444. _irq13:
  445.     cli
  446.     push byte 0
  447.     push byte 45
  448.     jmp irq_common_stub
  449.  
  450. ; 46: IRQ14
  451. _irq14:
  452.     cli
  453.     push byte 0
  454.     push byte 46
  455.     jmp irq_common_stub
  456.  
  457. ; 47: IRQ15
  458. _irq15:
  459.     cli
  460.     push byte 0
  461.     push byte 47
  462.     jmp irq_common_stub
  463.  
  464. extern _irq_handler
  465.  
  466. irq_common_stub:
  467.     pusha
  468.     push ds
  469.     push es
  470.     push fs
  471.     push gs
  472.  
  473.     mov ax, 0x10
  474.     mov ds, ax
  475.     mov es, ax
  476.     mov fs, ax
  477.     mov gs, ax
  478.     mov eax, esp
  479.  
  480.     push eax
  481.     mov eax, _irq_handler
  482.     call eax
  483.     pop eax
  484.  
  485.     pop gs
  486.     pop fs
  487.     pop es
  488.     pop ds
  489.     popa
  490.     add esp, 8
  491.     iret
  492.  
  493. section .bss
  494. align 4
  495. stack:
  496. resb STACKSIZE



Per quanto rigurda la compilazione tutto :k:
ma quando vado a fare il linking mi esce questo messaggio di errore:
Codice sorgente - presumibilmente Delphi

  1. Undefined symbols for architecture i386:
  2.   "start", referenced from:
  3.      implicit entry/start for main executable
  4. ld: symbol(s) not found for architecture i386



E non capisco il perché! Come comandi uso:
Codice sorgente - presumibilmente Plain Text

  1. nasm -f macho loader/loader.S -o $build/loader.o
  2. gcc -m32 -Wall kernel/kernel.c -o $build/kernel.o
  3. ld -arch i386 -map linker/linker.ld -o kernel.bin $build/loader.o $build/kernel.o ...



Riepilogo:
Compilazione NASM :k:
Compilazione GCC :k:
Linking :nono:

Qualcuno sa aiutarmi?

Grazie :k:

P.S: Su Ubuntu funziona tutto a meraviglia; è solo su Mac che non vuole saperne di funzionare! :k:

Edit: Risolto! Non riusciva a trovare la funzione d'ingresso 'start' che in questo codice è chiamata loader, mi è bastato cambiare 'loader' con 'start' e tutto è andato a buon fine! :D:k:

Ultima modifica effettuata da LittleHacker il 12/04/2013 alle 8:40
PM Quote