[PATCH] improve mig building guide

2024-02-02 Thread Pasha (biblio)
From: "pasha (biblio)" 

---
 microkernel/mach/mig/gnu_mig/building.mdwn | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/microkernel/mach/mig/gnu_mig/building.mdwn 
b/microkernel/mach/mig/gnu_mig/building.mdwn
index f335aa73..8f919aa7 100644
--- a/microkernel/mach/mig/gnu_mig/building.mdwn
+++ b/microkernel/mach/mig/gnu_mig/building.mdwn
@@ -84,7 +84,7 @@ configure:
 $ GNU=~/gnu
 $ TARGET_CPPFLAGS=-I"$GNU"/include ../configure --prefix="$GNU"
 
-If you are building on a 64 bit machine, you need to add a --target option:
+If you want to build 32-bit gnumach on a 64-bit machine, you need to add 
--target option (i686-gnu or i686-linux-gnu). mig(com) will be build as ELF64 
binary, but it will generate 32-bit code for gnumach:
 
 $ GNU=~/gnu
 $ TARGET_CPPFLAGS=-I"$GNU"/include ../configure --prefix="$GNU" 
--target=i686-gnu TARGET_CC=i686-linux-gnu-gcc
@@ -93,6 +93,11 @@ Build and install the Mach Interface Generator into _$GNU_ 
(i.e. _~/gnu/_ in our
 
 $ make all install
 
+In case of --target 32-bit, mig might be installed as i686-(linux)-gnu-mig. 
Create a symbolic link for mig:
+
+   $ cd ~/gnu/bin/
+   $ ln -s i686-linux-gnu-mig mig
+
 To make your _mig_ binary easily available, you should append something like
 the following to e.g. your _~/.bash\_profile_:
 
@@ -102,3 +107,12 @@ the following to e.g. your _~/.bash\_profile_:
 If you already have e.g. _~/bin_ in your _$PATH_, you could also create a 
symbolic link:
 
 $ ln -s ~/gnu/bin/mig ~/bin/
+
+For advance users, if you want to build mig(com) as ELF32 binary to copy to a 
32-bit machine or any other purposes, you need to add --host, LD, CC options:
+
+   $ TARGET_CPPFLAGS=-I"$GNU"/include ../configure --prefix="$GNU" 
--target=i686-linux-gnu TARGET_CC=i686-linux-gnu-gcc \
+ --host=i686-gnu LD=i686-linux-gnu-ld CC=i686-linux-gnu-gcc
+
+You may verify using:
+
+   $ readelf -h ~/gnu/libexec/i686-linux-gnu-migcom
-- 
2.39.2




Re: [PATCH] improve mig building guide

2024-02-02 Thread Samuel Thibault
Hello,

Pasha (biblio), le ven. 02 févr. 2024 18:26:05 +0100, a ecrit:
> @@ -93,6 +93,11 @@ Build and install the Mach Interface Generator into _$GNU_ 
> (i.e. _~/gnu/_ in our
>  
>  $ make all install
>  
> +In case of --target 32-bit, mig might be installed as i686-(linux)-gnu-mig. 
> Create a symbolic link for mig:
> +
> + $ cd ~/gnu/bin/
> + $ ln -s i686-linux-gnu-mig mig

Mmm, that shouldn't be needed: if you pass --target=i686-gnu, it will be
called i686-gnu-mig, which gnumach's configure will find.


> @@ -102,3 +107,12 @@ the following to e.g. your _~/.bash\_profile_:
>  If you already have e.g. _~/bin_ in your _$PATH_, you could also create a 
> symbolic link:
>  
>  $ ln -s ~/gnu/bin/mig ~/bin/
> +
> +For advance users, if you want to build mig(com) as ELF32 binary to copy to 
> a 32-bit machine or any other purposes, you need to add --host, LD, CC 
> options:

Is this really useful?

Samuel



Re: [PATCH] improve mig building guide

2024-02-02 Thread Samuel Thibault
Pasha (biblio), le ven. 02 févr. 2024 18:26:05 +0100, a ecrit:
> From: "pasha (biblio)" 
> 
> ---
>  microkernel/mach/mig/gnu_mig/building.mdwn | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/microkernel/mach/mig/gnu_mig/building.mdwn 
> b/microkernel/mach/mig/gnu_mig/building.mdwn
> index f335aa73..8f919aa7 100644
> --- a/microkernel/mach/mig/gnu_mig/building.mdwn
> +++ b/microkernel/mach/mig/gnu_mig/building.mdwn
> @@ -84,7 +84,7 @@ configure:
>  $ GNU=~/gnu
>  $ TARGET_CPPFLAGS=-I"$GNU"/include ../configure --prefix="$GNU"
>  
> -If you are building on a 64 bit machine, you need to add a --target option:
> +If you want to build 32-bit gnumach on a 64-bit machine, you need to add 
> --target option (i686-gnu or i686-linux-gnu). mig(com) will be build as ELF64 
> binary, but it will generate 32-bit code for gnumach:
>  
>  $ GNU=~/gnu
>  $ TARGET_CPPFLAGS=-I"$GNU"/include ../configure --prefix="$GNU" 
> --target=i686-gnu TARGET_CC=i686-linux-gnu-gcc

I applied that part, thanks!

Samuel



Re: [PATCH 2/2 gnumach] smp: Use HPET instead of unreliable pit one-shot

2024-02-02 Thread Samuel Thibault
Hello,

Damien Zammit, le ven. 02 févr. 2024 06:40:04 +, a ecrit:
> ---
>  i386/i386/smp.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/i386/i386/smp.c b/i386/i386/smp.c
> index fb43ecb6..87f59913 100644
> --- a/i386/i386/smp.c
> +++ b/i386/i386/smp.c
> @@ -101,7 +100,7 @@ void smp_startup_cpu(unsigned apic_id, unsigned vector)
>  } while(lapic->icr_low.delivery_status == SEND_PENDING);
>  
>  /* Wait 10 msec */
> -pit_mdelay(10);
> +hpet_mdelay(10);
>  
>  /* Clear APIC errors */
>  lapic->error_status.r = 0;

We'd need to also fallback to pit_mdelay in case there is no HPET?

Samuel



Re: [PATCH 1/2 gnumach] Add HPET timer for small accurate delays

2024-02-02 Thread Samuel Thibault
Damien Zammit, le ven. 02 févr. 2024 06:39:57 +, a ecrit:
> diff --git a/i386/i386/apic.c b/i386/i386/apic.c
> index 0cf7c37c..e3d53ce3 100644
> --- a/i386/i386/apic.c
> +++ b/i386/i386/apic.c
> @@ -26,6 +26,9 @@
>  #include 
>  #include 
>  
> +uint32_t hpet_period_nsec;
> +
> +extern uint32_t *hpet_addr;

We'd rather avoid extern variable declarations outside .h files.

I know we still have some left in gnumach, but let's not add even more
:)

> +void
> +hpet_udelay(uint32_t us)
> +{
> +uint32_t start, finish, now;
> +
> +us *= NSEC_PER_USEC / hpet_period_nsec;

You'll be more precise by using

us = (us * NSEC_PER_USEC) / hpet_period_nsec;

Also, please loudly reject values which are not supported.

> +start = HPET32(HPET_COUNTER);
> +
> +finish = start + us;
> +
> +while (1) {
> +now = HPET32(HPET_COUNTER);
> +
> +if (finish > start) {
> +/* ticks did not wrap initially */
> +if (now >= finish)
> +break;
> +} else {
> +/* ticks wrapped initially */
> +if ((now < start) && (now >= finish))
> +break;
> +}

Can't you rather just subtract start from now, and check when it beyond
us?

Samuel