Kernel debugging / drivers (was: USB keyboard driver the GNU Mach)

2016-03-20 Thread Olaf Buddenhagen
Hi,

On Mon, Feb 29, 2016 at 12:41:43PM +0100, Justus Winter wrote:

> While we generally want to move away from drivers in the kernel, it
> might indeed be nice to have a keyboard driver inside it for kdb.

Hm, this is an interesting point. I haven't actually considered keyboard
drivers up till now; but there is an even bigger problem: as soon as you
are no longer running VGA text mode, kdb won't work without huge amounts
of graphics driver code in the kernel.

In the end, it seems we have to give up on the idea of kdb using
in-kernel console drivers. That doesn't mean we have to give up on a
kernel debugger though: we could load a self-contained, separate OS
alongside gnumach, which remains inactive until kdb (or the panic
handler) is invoked.

-antrik-



Re: [PATCH] Use uint32_t instead of unsigned32_t.

2016-03-20 Thread Flavio Cruz
* Makefile.am: Use -ffreestanding and remove -nostdinc since we are including 
stdint.h.
* i386/i386/xen.h: Use uint64_t.
* i386/include/mach/i386/machine_types.defs: Use uint32_t and int32_t.
* i386/include/mach/i386/vm_types.h: Remove definitions of int*, uint*,
unsigned* and signed* types.
* i386/xen/xen.c: Use uint64_t.
* include/device/device_types.defs: Use uint32_t.
* include/mach/std_types.defs: Use POSIX types.
* include/mach/std_types.h: Include stdint.h.
* include/sys/types.h: Include stdint.h.
* ipc/ipc_kmsg.c: Use uint64_t.
* kern/exception.c: Use uint32_t.
* xen/block.c: Use uint64_t.
* xen/net.c: Do not use removed unsigned*_t types.
* xen/ring.h: Use uint32_t instead.
* xen/store.c: Use uint32_t.
* xen/store.h: Use uint32_t.
* xen/time.c: Use POSIX types only.
* xen/time.h: Use uint64_t.
---

On Sun, Mar 20, 2016 at 11:55:10AM +0100, Thomas Schwinge wrote:
> Hi!
> 
> On Sun, 20 Mar 2016 00:30:30 +0100, Samuel Thibault  
> wrote:
> > Flávio Cruz, on Sat 19 Mar 2016 14:20:34 +0100, wrote:
> > > We already include mach/std_types.h in the stubs which provides uint32_t.
> 
> > Should gnumach perhaps just rely on stdint.h?
> 
> Relying on existing, standard header files generally makes sense.  As I
> understand it,  is part of the freestanding C implementation
> (see , for example).  (I'm aware that we
> currently don't built GNU Mach with -ffreestanding; but we should -- at
> least conceptually.)

I guess that makes sense since intN_t and uintN_t are part of the C99
standard. I've tried to compile GNU Mach using stdint.h and
-ffreestanding and so far so good, however I'm not sure if removing
-nostdinc is a good idea since we may include some files from
/usr/include that should not included (things like sys/types.h and
sys/time.h which are implemented in gnumach/include). I'm attaching the
patch below.

diff --git a/Makefile.am b/Makefile.am
index 1c1bfff..e9c8fec 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,7 +42,7 @@ AM_LDFLAGS =
 #
 
 AM_CPPFLAGS += \
-   -nostdinc -imacros config.h
+   -ffreestanding -imacros config.h
 
 AM_CPPFLAGS += \
-I$(systype) \
diff --git a/i386/i386/xen.h b/i386/i386/xen.h
index c681187..49b0d52 100644
--- a/i386/i386/xen.h
+++ b/i386/i386/xen.h
@@ -356,8 +356,8 @@ _hypcall2(int, set_debugreg, int, reg, unsigned long, 
value);
 _hypcall1(unsigned long, get_debugreg, int, reg);
 
 /* x86-specific */
-MACH_INLINE unsigned64_t hyp_cpu_clock(void) {
-   unsigned64_t tsc;
+MACH_INLINE uint64_t hyp_cpu_clock(void) {
+   uint64_t tsc;
asm volatile("rdtsc":"=A"(tsc));
return tsc;
 }
diff --git a/i386/include/mach/i386/machine_types.defs 
b/i386/include/mach/i386/machine_types.defs
index 6ac17cf..6ff93db 100755
--- a/i386/include/mach/i386/machine_types.defs
+++ b/i386/include/mach/i386/machine_types.defs
@@ -47,7 +47,7 @@
  * a port in user space as an integer and
  * in kernel space as a pointer.
  */
-type natural_t = unsigned32;
+type natural_t = uint32_t;
 
 /*
  * An integer_t is the signed counterpart
@@ -56,6 +56,6 @@ type natural_t = unsigned32;
  * other types in a machine-independent
  * way.
  */
-type integer_t = int32;
+type integer_t = int32_t;
 
 #endif /* _MACHINE_MACHINE_TYPES_DEFS_ */
diff --git a/i386/include/mach/i386/vm_types.h 
b/i386/include/mach/i386/vm_types.h
index 4a58b1c..4e259f9 100644
--- a/i386/include/mach/i386/vm_types.h
+++ b/i386/include/mach/i386/vm_types.h
@@ -59,16 +59,6 @@ typedef unsigned int natural_t;
  */
 typedef intinteger_t;
 
-#ifndef _POSIX_SOURCE
-
-/*
- * An int32 is an integer that is at least 32 bits wide
- */
-typedef intint32;
-typedef unsigned int   uint32;
-
-#endif /* _POSIX_SOURCE */
-
 /*
  * A vm_offset_t is a type-neutral pointer,
  * e.g. an offset into a virtual memory space.
@@ -92,20 +82,6 @@ typedef unsigned long phys_addr_t;
  */
 typedefnatural_t   vm_size_t;
 
-/*
- * These types are _exactly_ as wide as indicated in their names.
- */
-typedef signed charsigned8_t;
-typedef signed short   signed16_t;
-typedef signed int signed32_t;
-typedef signed long long   signed64_t;
-typedef unsigned char  unsigned8_t;
-typedef unsigned short unsigned16_t;
-typedef unsigned int   unsigned32_t;
-typedef unsigned long long unsigned64_t;
-typedef float  float32_t;
-typedef double float64_t;
-
 #endif /* __ASSEMBLER__ */
 
 /*
diff --git a/i386/xen/xen.c b/i386/xen/xen.c
index a46ee2c..44d37e6 100644
--- a/i386/xen/xen.c
+++ b/i386/xen/xen.c
@@ -46,7 +46,7 @@ void hyp_failsafe_c_callback(struct failsafe_callback_regs 
*regs) {
 
 extern void return_to_iret;
 
-void hypclock_machine_intr(int old_ipl, void *ret_addr, struct 
i386_interrupt_state *regs, unsigned64_t delta) {
+void hypclock_machine_intr(int old_ipl, void *ret_addr, struct 
i386_interrupt_state *regs, uint64_t delta) {
if (ret_addr == &return_to_iret) {

Re: [PATCH] Remove global netfs lock and use hard and soft references for nodes.

2016-03-20 Thread Justus Winter
Quoting Flávio Cruz (2016-03-18 01:27:37)
> > Looks fine otherwise,  I'll test it in my builds.
> 
> How does it work for you so far?

Very well.  Thanks for picking this up :)

Justus



Re: [PATCH] Use uint32_t instead of unsigned32_t.

2016-03-20 Thread Thomas Schwinge
Hi!

On Sun, 20 Mar 2016 00:30:30 +0100, Samuel Thibault  
wrote:
> Flávio Cruz, on Sat 19 Mar 2016 14:20:34 +0100, wrote:
> > We already include mach/std_types.h in the stubs which provides uint32_t.

> Should gnumach perhaps just rely on stdint.h?

Relying on existing, standard header files generally makes sense.  As I
understand it,  is part of the freestanding C implementation
(see , for example).  (I'm aware that we
currently don't built GNU Mach with -ffreestanding; but we should -- at
least conceptually.)


Grüße
 Thomas


signature.asc
Description: PGP signature