AHI moved to core
[AROS-Contrib.git] / necessary / AmberRAM / resident.c
blob7bea6b0896730887a94c48ed491299d647180ab6
1 /*
3 File: resident.c
4 Author: Neil Cafferkey
5 Copyright (C) 2008 Neil Cafferkey
7 This file is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
12 This file is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this file; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 MA 02111-1307, USA.
24 #include <aros/debug.h>
25 #include <exec/types.h>
26 #include <exec/resident.h>
27 #include <exec/alerts.h>
28 #include <dos/dosextens.h>
29 #include <dos/filehandler.h>
31 #include <proto/exec.h>
32 #include <proto/dos.h>
34 #include "handler.h"
36 #define _STR(A) #A
37 #define STR(A) _STR(A)
39 #define HANDLER_NAME "amberram.handler"
40 #define VERSION 1
41 #define REVISION 9
43 #ifdef __AROS__
44 #define rom_tag Ram_ROMTag
45 #endif
47 extern LONG Main(void);
49 static AROS_UFP3 (APTR, Init,
50 AROS_UFPA(struct Library *, lh, D0),
51 AROS_UFPA(BPTR, segList, A0),
52 AROS_UFPA(struct ExecBase *, sysBase, A6));
54 static const TEXT handler_name[] = HANDLER_NAME;
55 static const TEXT version_string[] =
56 HANDLER_NAME " " STR(VERSION) "." STR(REVISION) " (" __DATE__ ")\n";
57 static const TEXT dev_name[] = "RAM";
59 extern const TEXT dos_name[];
61 const struct Resident rom_tag =
63 RTC_MATCHWORD,
64 (struct Resident *)&rom_tag,
65 (APTR)(&rom_tag + 1),
66 RTF_AFTERDOS,
67 VERSION,
68 NT_PROCESS,
69 -125,
70 (STRPTR)handler_name,
71 (STRPTR)version_string,
72 (APTR)Init
75 #ifdef DOSBase
76 #undef DOSBase
77 #endif
79 static AROS_UFH3 (APTR, Init,
80 AROS_UFHA(struct Library *, lh, D0),
81 AROS_UFHA(BPTR, segList, A0),
82 AROS_UFHA(struct ExecBase *, sysBase, A6)
85 struct DosLibrary *DOSBase;
86 struct DeviceNode *dev_node;
88 AROS_USERFUNC_INIT
90 /* Create device node and add it to the system. The handler will then be
91 started when it is first accessed */
93 DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", DOS_VERSION);
94 dev_node = (APTR)MakeDosEntry(dev_name, DLT_DEVICE);
95 if(dev_node == NULL)
96 Alert(AT_DeadEnd | AG_NoMemory);
97 dev_node->dn_Handler = (STRPTR)handler_name;
98 dev_node->dn_StackSize = 10000;
99 dev_node->dn_SegList = MKBADDR((BPTR *)Main - 1);
100 if(!AddDosEntry((APTR)dev_node))
101 Alert(AT_DeadEnd);
103 AROS_USERFUNC_EXIT
105 return NULL;