revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-hosted / filesys / emul_handler / emul_init.c
blobb515a4d98b64461ebd4c9d23a29cf00ff12f567b
1 /*
2 Copyright 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Filesystem that accesses an underlying host OS filesystem.
6 Lang: english
7 */
9 /*********************************************************************************************/
11 #define DEBUG 0
13 #include <aros/debug.h>
14 #include <aros/symbolsets.h>
15 #include <libraries/expansion.h>
16 #include <resources/filesysres.h>
17 #include <proto/arossupport.h>
18 #include <proto/dos.h>
19 #include <proto/exec.h>
20 #include <proto/expansion.h>
22 #include "emul_intern.h"
23 #include LC_LIBDEFS_FILE
25 #include <limits.h>
26 #include <string.h>
27 #include <stddef.h>
29 static LONG startup(struct emulbase *emulbase)
31 APTR ExpansionBase;
33 D(bug("[Emulhandler] startup\n"));
35 HostLibBase = OpenResource("hostlib.resource");
36 D(bug("[EmulHandler] got hostlib.resource %p\n", HostLibBase));
37 if (!HostLibBase)
38 return FALSE;
40 KernelBase = OpenResource("kernel.resource");
41 D(bug("[EmulHandler] KernelBase = %p\n", KernelBase));
42 if (!KernelBase)
43 return FALSE;
45 emulbase->mempool = CreatePool(MEMF_ANY|MEMF_SEM_PROTECTED, 4096, 2000);
46 if (!emulbase->mempool)
47 return FALSE;
49 /* Create a BootNode so we can boot from this device */
50 if ((ExpansionBase = OpenLibrary("expansion.library", 0)))
52 struct DeviceNode *dn;
53 IPTR pp[4 + sizeof(struct DosEnvec)/sizeof(IPTR)] = {};
55 pp[0] = (IPTR)"EMU";
56 pp[1] = 0;
57 pp[2] = 0;
58 pp[DE_TABLESIZE + 4] = DE_DOSTYPE;
59 /* .... */
60 pp[DE_BUFMEMTYPE + 4] = MEMF_PUBLIC;
61 pp[DE_MASK + 4] = -1;
62 pp[DE_BOOTPRI + 4] = 0;
63 pp[DE_DOSTYPE + 4] = AROS_MAKE_ID('E', 'M', 'U', 0);
65 dn = MakeDosNode(pp);
66 if (dn)
68 dn->dn_SegList = CreateSegList(EmulHandlerMain);
69 dn->dn_Handler = AROS_CONST_BSTR("emul-handler");
70 dn->dn_StackSize = 16384;
71 dn->dn_GlobalVec = (BPTR)-1;
73 AddDosNode(0, ADNF_STARTPROC, dn);
76 CloseLibrary(ExpansionBase);
79 return TRUE;
82 ADD2INITLIB(startup, -10)
84 /*********************************************************************************************/
86 static LONG cleanup(struct emulbase *emulbase)
88 if (emulbase->mempool)
89 DeletePool(emulbase->mempool);
91 return TRUE;
94 ADD2EXPUNGELIB(cleanup, 10);