2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 Desc: Add a segment to the resident list.
8 #include "dos_intern.h"
10 #include <proto/exec.h>
12 /*****************************************************************************
15 #include <dos/dosextens.h>
16 #include <proto/dos.h>
18 AROS_LH3(BOOL
, AddSegment
,
21 AROS_LHA(CONST_STRPTR
, name
, D1
),
22 AROS_LHA(BPTR
, seg
, D2
),
23 AROS_LHA(LONG
, type
, D3
),
26 struct DosLibrary
*, DOSBase
, 129, Dos
)
29 Adds a program segment to the system resident list. You can later
30 use these segments to run programs.
32 The name field should refer to a NULL terminated strings, which
33 will be copied. The type field determines the type of resident
34 program. Normal programs should have type >= 0, system segments
35 should have type == CMD_SYSTEM.
37 Note that all other values of type are reserved.
40 name - Name of the segment. This is used by FindSegment().
42 type - What type of segment (initial use count).
45 Segment will have been added to the DOS resident list.
55 Uses Forbid() based locking.
58 FindSegment(), RemSegment()
62 *****************************************************************************/
68 int namelen
= strlen(name
) + 1;
72 if (FindSegment(name
, NULL
, type
)) {
77 sptr
= AllocVec(sizeof(struct Segment
) + namelen
- 4 + 1,
78 MEMF_CLEAR
| MEMF_PUBLIC
);
85 dinf
= BADDR(DOSBase
->dl_Root
->rn_Info
);
91 CopyMem(name
, sptr
->seg_Name
, namelen
);
93 CopyMem(name
, &sptr
->seg_Name
[1], namelen
);
94 sptr
->seg_Name
[0] = namelen
- 1;
97 /* Sigh, we just add the segment to the start of the list */
98 sptr
->seg_Next
= dinf
->di_ResList
;
99 dinf
->di_ResList
= MKBADDR(sptr
);