summaryrefslogtreecommitdiff
path: root/sys/arch/amiga/stand/loadbsd/poolmem.c
blob: 2058acf25fce2c76c0a6f99f0aa505dcf8e312d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* $OpenBSD: poolmem.c,v 1.1 1998/08/13 21:08:16 espie Exp $ */

/* This piece of code ensures that poolmem no longer runs. It is necessary
 * to kill poolmem before assessing the memory configuration, as this patch
 * tampers with exec memory lists

 From: Thomas Richter <thor@math.TU-Berlin.DE>

The following is the "official" port structure of the PoolMem port. That's
what you get as result of a FindPort("PoolMem.rendezvous"):

struct PoolMemPort {
	struct MsgPort		pm_Port;
	UWORD			pm_Flags;          DO NOT CARE 
	ULONG			pm_DoNotTouch;
	void		      (*pm_RemoveProc)();  The important stuff 
};

Calling syntax is as follows:

	The remove procedure must be called with Exec in "Forbid" state,
	using register a0 as a pointer to the routine. Register a6 MUST be
	a pointer to the DosLibrary (purely for historical reasons).
	Register a5 MUST be a pointer to this port structure.
 */
 
#include <proto/exec.h>
#include <stdio.h>

extern struct DosLibrary *DOSBase;
void remove_poolmem(struct DosLibrary *db, struct MsgPort *mp);


void ensure_no_poolmem()
   {
   Forbid();
      {
      struct MsgPort *p = FindPort("PoolMem.rendezvous");
      if (p)
	 remove_poolmem(DOSBase, p);
		/* this will actually break the Forbid() */
	 puts("Poolmem detected (and removed)");
      }
   Permit();
   }

asm("
	.text
	.globl _remove_poolmem

_remove_poolmem:
        movem.l a0-a6/d0-d7,sp@-		| save all regs
	move.l sp@(64),a6			| DosBase
	move.l sp@(68),a5			| PoolMemPort
	move.l  a5@(40),a0		| Routine to call
	jsr  a0@
	movem.l sp@+,a0-a6/d0-d7		| restore all regs
	rts
");