caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Multiboot problem
@ 2008-01-14 10:03 David LONY
  2008-01-14 13:24 ` [Caml-list] " David LONY
  0 siblings, 1 reply; 4+ messages in thread
From: David LONY @ 2008-01-14 10:03 UTC (permalink / raw)
  To: caml-list

Hi all,

I'm currently trying to make a multiboot sector with ocaml code. 
Unfortunately, it doesn't work bu I don't know why...
To do that, I made a small program in ocaml :

let test_char a = a+1
let _ = Callback.register "caml_test_char" test_char;;

I also made a dummy libc  (all functions return 0 or NULL pointer) 
because I have to provide all these functions if a wants to statically 
link a C objects..
This is my main file with the entry point of the kernel :

/* Include definitions of the multiboot standard */
#include <multiboot.h>
#include <x86_videomem.h>
#include <caml/mlvalues.h>
#include <caml/callback.h>

/* This is the entry point of the kernel */
void sos_main(unsigned long magic, unsigned long addr)
{
  static char * argv[]={ "ocaml", NULL };

  multiboot_info_t *mbi;

  /* Retrieve grub information (memory...etc) */
  mbi = (multiboot_info_t *) addr;
 
  caml_startup(argv);
 
  /* Clean the screen and put a 'A' on it */
  sos_x86_videomem_setup();
  sos_x86_videomem_cls(SOS_X86_VIDEO_BG_BLACK);
  sos_x86_videomem_putchar(1, 0, SOS_X86_VIDEO_FG_WHITE | 
SOS_X86_VIDEO_BG_BLACK,'A');
 
  /* An operatig system never ends */
  for (;;)
    continue;

  return;
}


But qemu freezes when I call the caml_startup function (If I removed it, 
it works well...)...Perhaps the caml_startup function relies on C 
function that I don't implements ?
If someone have an idea.... Because I must call this function 
(caml_startup) in order to call my ocaml function (test_char)...


Thanks a lot.
Regards,
David LONY



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Multiboot problem
  2008-01-14 10:03 Multiboot problem David LONY
@ 2008-01-14 13:24 ` David LONY
  2008-01-14 15:06   ` Eric Cooper
  2008-01-24 16:04   ` David LONY
  0 siblings, 2 replies; 4+ messages in thread
From: David LONY @ 2008-01-14 13:24 UTC (permalink / raw)
  To: caml-list

Does anyone can explain to me how the function caml_startup works ? Does 
it relies on malloc or free function or any functions of the C library ?
I've tried to look for an explanation on the Ocaml manual but I found 
nothing...

Regards.
David LONY

David LONY a écrit :
> Hi all,
>
> I'm currently trying to make a multiboot sector with ocaml code. 
> Unfortunately, it doesn't work bu I don't know why...
> To do that, I made a small program in ocaml :
>
> let test_char a = a+1
> let _ = Callback.register "caml_test_char" test_char;;
>
> I also made a dummy libc  (all functions return 0 or NULL pointer) 
> because I have to provide all these functions if a wants to statically 
> link a C objects..
> This is my main file with the entry point of the kernel :
>
> /* Include definitions of the multiboot standard */
> #include <multiboot.h>
> #include <x86_videomem.h>
> #include <caml/mlvalues.h>
> #include <caml/callback.h>
>
> /* This is the entry point of the kernel */
> void sos_main(unsigned long magic, unsigned long addr)
> {
>  static char * argv[]={ "ocaml", NULL };
>
>  multiboot_info_t *mbi;
>
>  /* Retrieve grub information (memory...etc) */
>  mbi = (multiboot_info_t *) addr;
>
>  caml_startup(argv);
>
>  /* Clean the screen and put a 'A' on it */
>  sos_x86_videomem_setup();
>  sos_x86_videomem_cls(SOS_X86_VIDEO_BG_BLACK);
>  sos_x86_videomem_putchar(1, 0, SOS_X86_VIDEO_FG_WHITE | 
> SOS_X86_VIDEO_BG_BLACK,'A');
>
>  /* An operatig system never ends */
>  for (;;)
>    continue;
>
>  return;
> }
>
>
> But qemu freezes when I call the caml_startup function (If I removed 
> it, it works well...)...Perhaps the caml_startup function relies on C 
> function that I don't implements ?
> If someone have an idea.... Because I must call this function 
> (caml_startup) in order to call my ocaml function (test_char)...
>
>
> Thanks a lot.
> Regards,
> David LONY
>
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Multiboot problem
  2008-01-14 13:24 ` [Caml-list] " David LONY
@ 2008-01-14 15:06   ` Eric Cooper
  2008-01-24 16:04   ` David LONY
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Cooper @ 2008-01-14 15:06 UTC (permalink / raw)
  To: caml-list

> Does anyone can explain to me how the function caml_startup works ?

The source is in asmrun/startup.c.

> Does it relies on malloc or free function or any functions of the C
> library ?

Yes.  In addition to utility functions like printf and scanf, it calls
the runtime system functions defined in byterun/, like GC
initialization, which calls malloc.

-- 
Eric Cooper             e c c @ c m u . e d u


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Multiboot problem
  2008-01-14 13:24 ` [Caml-list] " David LONY
  2008-01-14 15:06   ` Eric Cooper
@ 2008-01-24 16:04   ` David LONY
  1 sibling, 0 replies; 4+ messages in thread
From: David LONY @ 2008-01-24 16:04 UTC (permalink / raw)
  To: caml-list

Hi all,

I continue my multiboot sector but I'm blocked...To do so, I have 
implemented a dummy libC like the Funk project (But all function return 
a NULL pointer or 0).
I'm trying to call the caml_startup function but it freeze. So I look 
into Ocaml source to know on which function it relies.
Then in my main I call (instead of caml_startup) 
caml_init_ieee_floats(), caml_stat_alloc(), 
caml_register_custom_operations()...

I put debug information on all my functions to know which functions are 
called. Then the caml_stat_alloc work well but if I call the 
caml_register_custom_operations function it freeze...
So I copy the code of the caml_register_custom_operations function and 
renamed it caml_register_custom_operations1...I removed all code of this 
function (so the function do nothing)...

So if I call caml_stat_alloc() function it work...
If I call the caml_register_custom_operations1 it work also
But if I call the caml_stat_alloc() and the 
caml_register_custom_operations1 after... It freeze.... And I don't know 
why!!!

There is the code... If someone has an idea....

Regards
David LONY


/* Include definitions of the multiboot standard */
#include <multiboot.h>
#include <x86_videomem.h>
#include <caml/mlvalues.h>
#include <caml/callback.h>

struct custom_operations_list {
  struct custom_operations * ops;
  struct custom_operations_list * next;
};

extern struct custom_operations caml_int32_ops;

void caml_register_custom_operations1(struct custom_operations * ops)
{
sos_x86_videomem_putstring(1, 0, SOS_X86_VIDEO_FG_WHITE | 
SOS_X86_VIDEO_BG_BLACK,"caml_register_custom_operations1");
}

/* The C entry point of our operating system */
void sos_main(unsigned long magic, unsigned long addr)
{
  static char * argv[]={ "ocaml", NULL };
  int test;
  int result=11;

  multiboot_info_t *mbi;
  mbi = (multiboot_info_t *) addr;

  sos_x86_videomem_setup();
  sos_x86_videomem_cls(SOS_X86_VIDEO_BG_BLACK);
  if(result == 11)
  {
        sos_x86_videomem_putchar(1, 0, SOS_X86_VIDEO_FG_WHITE | 
SOS_X86_VIDEO_BG_BLACK,'A');
  }
  else
  {
        sos_x86_videomem_putchar(1, 0, SOS_X86_VIDEO_FG_WHITE | 
SOS_X86_VIDEO_BG_BLACK,'B');
  }

caml_init_ieee_floats();
test  = caml_stat_alloc(sizeof(int));
caml_register_custom_operations1(&caml_int32_ops);

  /* An operatig system never ends */
  for (;;)
    continue;
}



David LONY a écrit :
> Does anyone can explain to me how the function caml_startup works ? 
> Does it relies on malloc or free function or any functions of the C 
> library ?
> I've tried to look for an explanation on the Ocaml manual but I found 
> nothing...
>
> Regards.
> David LONY
>
> David LONY a écrit :
>> Hi all,
>>
>> I'm currently trying to make a multiboot sector with ocaml code. 
>> Unfortunately, it doesn't work bu I don't know why...
>> To do that, I made a small program in ocaml :
>>
>> let test_char a = a+1
>> let _ = Callback.register "caml_test_char" test_char;;
>>
>> I also made a dummy libc  (all functions return 0 or NULL pointer) 
>> because I have to provide all these functions if a wants to 
>> statically link a C objects..
>> This is my main file with the entry point of the kernel :
>>
>> /* Include definitions of the multiboot standard */
>> #include <multiboot.h>
>> #include <x86_videomem.h>
>> #include <caml/mlvalues.h>
>> #include <caml/callback.h>
>>
>> /* This is the entry point of the kernel */
>> void sos_main(unsigned long magic, unsigned long addr)
>> {
>>  static char * argv[]={ "ocaml", NULL };
>>
>>  multiboot_info_t *mbi;
>>
>>  /* Retrieve grub information (memory...etc) */
>>  mbi = (multiboot_info_t *) addr;
>>
>>  caml_startup(argv);
>>
>>  /* Clean the screen and put a 'A' on it */
>>  sos_x86_videomem_setup();
>>  sos_x86_videomem_cls(SOS_X86_VIDEO_BG_BLACK);
>>  sos_x86_videomem_putchar(1, 0, SOS_X86_VIDEO_FG_WHITE | 
>> SOS_X86_VIDEO_BG_BLACK,'A');
>>
>>  /* An operatig system never ends */
>>  for (;;)
>>    continue;
>>
>>  return;
>> }
>>
>>
>> But qemu freezes when I call the caml_startup function (If I removed 
>> it, it works well...)...Perhaps the caml_startup function relies on C 
>> function that I don't implements ?
>> If someone have an idea.... Because I must call this function 
>> (caml_startup) in order to call my ocaml function (test_char)...
>>
>>
>> Thanks a lot.
>> Regards,
>> David LONY
>>
>>
>> _______________________________________________
>> Caml-list mailing list. Subscription management:
>> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
>> Archives: http://caml.inria.fr
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>>
>>
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-24 15:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-14 10:03 Multiboot problem David LONY
2008-01-14 13:24 ` [Caml-list] " David LONY
2008-01-14 15:06   ` Eric Cooper
2008-01-24 16:04   ` David LONY

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).