Skip to contentSkip to conversation

mini-os: replace lib/printf.c with a version not under GPL

PATCH Superseded Juergen Gross 3 participants 5 messages Jul 1, 2016 – Jul 12, 2016 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mini-os: replace lib/printf.c with a version not under GPL

Instead of a Linux kernel based implementation use one from freeBSD.

---
I'm not sure about coding style here: should I keep (more or less) the one from freeBSD, or is the Xen style preferred?

---
 blkfront.c        |    4 -
 include/lib-gpl.h |    7 +-
 lib/printf.c      | 1744 +++++++++++++++++++++++++++++++++--------------------
 tpmback.c         |    4 -
 4 files changed, 1100 insertions(+), 659 deletions(-)
blkfront.c +0 -4
index bdb7765..f747216 100644
@@ -17,10 +17,6 @@
 #include <mini-os/lib.h>
 #include <fcntl.h>
 
-#ifndef HAVE_LIBC
-#define strtoul simple_strtoul
-#endif
-
 /* Note: we generally don't need to disable IRQs since we hardly do anything in
  * the interrupt handler.  */
 
include/lib-gpl.h +3 -4
index d5602b2..7557627 100644
@@ -33,10 +33,9 @@
 
 #ifndef HAVE_LIBC
 /* printing */
-extern unsigned long simple_strtoul(const char *,char **,unsigned int);
-extern long simple_strtol(const char *,char **,unsigned int);
-extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
-extern long long simple_strtoll(const char *,char **,unsigned int);
+unsigned long strtoul(const char *nptr, char **endptr, int base);
+int64_t strtoq(const char *nptr, char **endptr, int base);
+uint64_t strtouq(const char *nptr, char **endptr, int base);
 
 extern int sprintf(char * buf, const char * fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
lib/printf.c +1097 -647

1,816 lines not on this page · raw message

tpmback.c +0 -4
index 00b66e8..22adbd3 100644
@@ -52,10 +52,6 @@
 #include <mini-os/wait.h>
 
 
-#ifndef HAVE_LIBC
-#define strtoul simple_strtoul
-#endif
-
 //#define TPMBACK_PRINT_DEBUG
 #ifdef TPMBACK_PRINT_DEBUG
 #define TPMBACK_DEBUG(fmt,...) printk("Tpmback:Debug("__FILE__":%d) " fmt, __LINE__, ##__VA_ARGS__)
Signature · 7 lines
2.6.6


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

Hello,

Quoted 1 line · Juergen Gross, on Fri 01 Jul 2016 11:33:27 +0200, wrote:

Instead of a Linux kernel based implementation use one from freeBSD.

That'd be useful indeed :)

Quoted 2 lines

I'm not sure about coding style here: should I keep (more or less) the one from freeBSD, or is the Xen style preferred?

I'd say just keep the file as it is upstream, so we can sync more easily in the future.

include/lib-gpl.h

Quoted 4 lines
include/lib-gpl.h +0 -0
index d5602b2..7557627 100644

Please move the content to lib.h then, since it won't be gpl any more.

Did you check the boot output e.g. of a trivial mini-os application? Notably, iirc there were perhaps odd formating with %x, %p or such. Moving to the posix behavior would be a good thing, I'd just want to know whether we have some behavior change.

Thanks,
Samuel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 5 lines · Samuel Thibault

Hello,

Quoted 1 line · Juergen Gross, on Fri 01 Jul 2016 11:33:27 +0200, wrote:

Instead of a Linux kernel based implementation use one from freeBSD.

Quoted 7 lines

That'd be useful indeed :)

Quoted 2 lines

I'm not sure about coding style here: should I keep (more or less) the one from freeBSD, or is the Xen style preferred?

I'd say just keep the file as it is upstream, so we can sync more easily in the future.

Okay, thanks.

Quoted 7 lines

include/lib-gpl.h

Quoted 5 lines
include/lib-gpl.h +0 -0
index d5602b2..7557627 100644

Please move the content to lib.h then, since it won't be gpl any more.

Okay.

Quoted 4 lines

Did you check the boot output e.g. of a trivial mini-os application? Notably, iirc there were perhaps odd formating with %x, %p or such. Moving to the posix behavior would be a good thing, I'd just want to know whether we have some behavior change.

Just double checked: some of the prints are now without leading zeroes:

Without my patch:

Xen Minimal OS!
start_info: 0000000000074000(VA)

    nr_pages: 0x1000
  shared_inf: 0xd7450000(MA)
     pt_base: 0000000000077000(VA)
nr_pt_frames: 0x5
    mfn_list: 000000000006c000(VA)
   mod_start: 0x0(VA)
     mod_len: 0
       flags: 0x0
    cmd_line:
       stack: 000000000002b540-000000000004b540
MM: Init
      _text: 0000000000000000(VA)
     _etext: 0000000000017708(VA)
   _erodata: 000000000001e000(VA)
     _edata: 000000000001e480(VA)
stack start: 000000000002b540(VA)
       _end: 000000000006ba58(VA)
  start_pfn: 7f
    max_pfn: 1000

Mapping memory range 0x7f000 - 0x1000000
setting 0000000000000000-000000000001e000 readonly
skipped 1000
MM: Initialise page allocator for 85000(85000)-1000000(1000000)
MM: done
Demand map pfns at 1001000-0000002001001000.
Initialising timer interface
Initialising console ... done.
gnttab_table mapped at 0000000001001000.
Initialising scheduler
Thread "Idle": pointer: 0x0000000000090070, stack: 0x00000000000a0000 Thread "xenstore": pointer: 0x00000000000900d0, stack: 0x00000000000b0000 xenbus initialised on irq 1 mfn 0x116675
Thread "shutdown": pointer: 0x0000000000090130, stack: 0x00000000000c0000 kernel.c: dummy main: start_info=000000000004b540

With my patch:

Xen Minimal OS!
start_info: 0x75000(VA)

    nr_pages: 0x1000
  shared_inf: 0xdb0b0000(MA)
     pt_base: 0x78000(VA)
nr_pt_frames: 0x5
    mfn_list: 0x6d000(VA)
   mod_start: 0x0(VA)
     mod_len: 0
       flags: 0x0
    cmd_line:
       stack: 0x2c580-0x4c580
MM: Init
      _text: 0(VA)
     _etext: 0x183fc(VA)
   _erodata: 0x1f000(VA)
     _edata: 0x1f4c0(VA)
stack start: 0x2c580(VA)
       _end: 0x6ca98(VA)
  start_pfn: 80
    max_pfn: 1000

Mapping memory range 0x80000 - 0x1000000
setting 0-0x1f000 readonly
skipped 1000
MM: Initialise page allocator for 86000(86000)-1000000(1000000)
MM: done
Demand map pfns at 1001000-0x2001001000.
Initialising timer interface
Initialising console ... done.
gnttab_table mapped at 0x1001000.
Initialising scheduler
Thread "Idle": pointer: 0x0x91070, stack: 0x0xa0000 Thread "xenstore": pointer: 0x0x910d0, stack: 0x0xb0000 xenbus initialised on irq 1 mfn 0x11aa76
Thread "shutdown": pointer: 0x0x91130, stack: 0x0xc0000 kernel.c: dummy main: start_info=0x4c580

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw

Hello,

Quoted 6 lines · Juergen Gross, on Mon 04 Jul 2016 07:29:46 +0200, wrote:
Quoted 4 lines

Did you check the boot output e.g. of a trivial mini-os application? Notably, iirc there were perhaps odd formating with %x, %p or such. Moving to the posix behavior would be a good thing, I'd just want to know whether we have some behavior change.

Just double checked: some of the prints are now without leading zeroes:

Ok, so %p moves from %08x to 0x%x. That's fine by me, anybody against the change?

Samuel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 8 lines · Samuel Thibault

Hello,

Quoted 5 lines · Juergen Gross, on Mon 04 Jul 2016 07:29:46 +0200, wrote:
Quoted 4 lines

Did you check the boot output e.g. of a trivial mini-os application? Notably, iirc there were perhaps odd formating with %x, %p or such. Moving to the posix behavior would be a good thing, I'd just want to know whether we have some behavior change.

Quoted 5 lines
Quoted 1 line

Just double checked: some of the prints are now without leading zeroes:

Ok, so %p moves from %08x to 0x%x. That's fine by me, anybody against the change?

No objection from me. :-)

If you ack this patch I will just queue it.

Wei.

Quoted 6 lines

Samuel

_______________________________________________
Minios-devel mailing list
[email protected]
http://lists.xenproject.org/cgi-bin/mailman/listinfo/minios-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel