Skip to content

Instantly share code, notes, and snippets.

@chainq
Created March 25, 2023 10:52
Show Gist options
  • Save chainq/0b1a628916a32ee6d93d9749de2d087c to your computer and use it in GitHub Desktop.
Save chainq/0b1a628916a32ee6d93d9749de2d087c to your computer and use it in GitHub Desktop.
NetBSD Console Debug patch
diff --git a/sys/arch/amiga/stand/bootblock/boot/console.c b/sys/arch/amiga/stand/bootblock/boot/console.c
index 08cb523adccd..801be4cc5c95 100644
--- a/sys/arch/amiga/stand/bootblock/boot/console.c
+++ b/sys/arch/amiga/stand/bootblock/boot/console.c
@@ -43,6 +43,24 @@
#include "amigaio.h"
#include "libstubs.h"
+int32_t EasyRequestArgs(void *, void *, u_int32_t *, void *);
+
+struct EasyStruct {
+ u_int32_t es_StructSize;
+ u_int32_t es_Flags;
+ char *es_Title;
+ char *es_TextFormat;
+ char *es_GadgetFormat;
+};
+
+const u_int32_t dbg[] = {
+ sizeof(struct EasyStruct),
+ 0L,
+ (u_int32_t)"DEBUG",
+ (u_int32_t)"cannot open console.device! %ld",
+ (u_int32_t)"OK"
+};
+
const u_int32_t screentags[] = {
SA_Type, CUSTOMSCREEN,
SA_DisplayID, 0x8000,
@@ -107,6 +125,7 @@ conspreinit(void)
int
consinit(void *consptr) {
struct Console *mc;
+ u_int32_t errc;
if (consptr != NULL) {
/* Check magic? */
@@ -138,8 +157,14 @@ consinit(void *consptr) {
goto err;
mc->cnior->buf = (void *)mc->w;
+ mc->cnior->length = 136; /* sizeof(struct Window) */
if (OpenDevice("console.device", 0, mc->cnior, 0))
+ {
+ errc = mc->cnior->err;
+ EasyRequestArgs(mc->w,(void *)&dbg,0L,&errc);
goto err;
+ }
+
mc->tmior = (struct TimerIO *)CreateIORequest(mc->cnmp, sizeof(struct TimerIO));
if (!mc->tmior)
diff --git a/sys/arch/amiga/stand/bootblock/boot/libstubs.s b/sys/arch/amiga/stand/bootblock/boot/libstubs.s
index 6ffdaf896bf0..b815568c1fee 100644
--- a/sys/arch/amiga/stand/bootblock/boot/libstubs.s
+++ b/sys/arch/amiga/stand/bootblock/boot/libstubs.s
@@ -238,6 +238,22 @@ ENTRY_NOPROFILE(Permit)
.comm _C_LABEL(IntuitionBase),4
+ENTRY_NOPROFILE(EasyRequestArgs)
+ movl %a6,%sp@-
+ movl %a2,%sp@-
+ movl %a3,%sp@-
+ movl %pc@(_C_LABEL(IntuitionBase):w),%a6
+ movl %sp@(16),%a0
+ movl %sp@(20),%a1
+ movl %sp@(24),%a2
+ movl %sp@(28),%a3
+ jsr %a6@(-0x24c)
+ movl %sp@+,%a3
+ movl %sp@+,%a2
+ movl %sp@+,%a6
+ rts
+
+
ENTRY_NOPROFILE(OpenScreenTagList)
movl %a6,%sp@-
movl %pc@(_C_LABEL(IntuitionBase):w),%a6
@polluks2
Copy link

mc->cnior->length = 136; /* sizeof(struct Window) */ why as a comment?

@chainq
Copy link
Author

chainq commented Mar 25, 2023

Because the NetBSD bootblock compiles w/o the AmigaOS NDK/SDK or whatever it's called this week, and they implemented part of the headers that is absolutely needed. Therefore struct Window is not available, so you can't sizeof it. So the comment just explains what that magic number actually is.

I mean, I technically could have declared a 136 byte dummy struct as Window, and sizeof it, but ... It's messy either way. Pick your poison.

@polluks2
Copy link

polluks2 commented Mar 26, 2023

I see, well done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment