1 /* The kernel call implemented in this file:
4 * The parameters for this kernel call are:
5 * m4_l3: SEG_PHYS (physical base address)
6 * m4_l4: SEG_SIZE (size of segment)
7 * m4_l1: SEG_SELECT (return segment selector here)
8 * m4_l2: SEG_OFFSET (return offset within segment here)
9 * m4_l5: SEG_INDEX (return index into remote memory map here)
11 #include "../system.h"
15 /*===========================================================================*
17 *===========================================================================*/
18 PUBLIC
int do_segctl(m_ptr
)
19 register message
*m_ptr
; /* pointer to request message */
21 /* Return a segment selector and offset that can be used to reach a physical
22 * address, for use by a driver doing memory I/O in the A0000 - DFFFF range.
27 register struct proc
*rp
;
28 phys_bytes phys
= (phys_bytes
) m_ptr
->SEG_PHYS
;
29 vir_bytes size
= (vir_bytes
) m_ptr
->SEG_SIZE
;
32 /* First check if there is a slot available for this segment. */
33 rp
= proc_addr(who_p
);
35 for (i
=0; i
< NR_REMOTE_SEGS
; i
++) {
36 if (! rp
->p_priv
->s_farmem
[i
].in_use
) {
38 rp
->p_priv
->s_farmem
[i
].in_use
= TRUE
;
39 rp
->p_priv
->s_farmem
[i
].mem_phys
= phys
;
40 rp
->p_priv
->s_farmem
[i
].mem_len
= size
;
44 if (index
< 0) return(ENOSPC
);
46 offset
= alloc_remote_segment(&selector
, &rp
->p_seg
,
47 i
, phys
, size
, USER_PRIVILEGE
);
50 /* Request successfully done. Now return the result. */
51 m_ptr
->SEG_INDEX
= index
| REMOTE_SEG
;
52 m_ptr
->SEG_SELECT
= selector
;
53 m_ptr
->SEG_OFFSET
= offset
;
57 #endif /* USE_SEGCTL */