[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / arch / i386 / transitions / librm_mgmt.c
blobf00be8117021363faafc22aeafdf037578ccf9fc
1 /*
2 * librm: a library for interfacing to real-mode code
4 * Michael Brown <mbrown@fensystems.co.uk>
6 */
8 FILE_LICENCE ( GPL2_OR_LATER );
10 #include <stdint.h>
11 #include <realmode.h>
14 * This file provides functions for managing librm.
18 /**
19 * Allocate space on the real-mode stack and copy data there from a
20 * user buffer
22 * @v data User buffer
23 * @v size Size of stack data
24 * @ret sp New value of real-mode stack pointer
26 uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) {
27 userptr_t rm_stack;
28 rm_sp -= size;
29 rm_stack = real_to_user ( rm_ss, rm_sp );
30 memcpy_user ( rm_stack, 0, data, 0, size );
31 return rm_sp;
34 /**
35 * Deallocate space on the real-mode stack, optionally copying back
36 * data to a user buffer.
38 * @v data User buffer
39 * @v size Size of stack data
41 void remove_user_from_rm_stack ( userptr_t data, size_t size ) {
42 if ( data ) {
43 userptr_t rm_stack = real_to_user ( rm_ss, rm_sp );
44 memcpy_user ( rm_stack, 0, data, 0, size );
46 rm_sp += size;
49 PROVIDE_UACCESS_INLINE ( librm, phys_to_user );
50 PROVIDE_UACCESS_INLINE ( librm, user_to_phys );
51 PROVIDE_UACCESS_INLINE ( librm, virt_to_user );
52 PROVIDE_UACCESS_INLINE ( librm, user_to_virt );
53 PROVIDE_UACCESS_INLINE ( librm, userptr_add );
54 PROVIDE_UACCESS_INLINE ( librm, memcpy_user );
55 PROVIDE_UACCESS_INLINE ( librm, memmove_user );
56 PROVIDE_UACCESS_INLINE ( librm, memset_user );
57 PROVIDE_UACCESS_INLINE ( librm, strlen_user );
58 PROVIDE_UACCESS_INLINE ( librm, memchr_user );