mirror of
https://github.com/xcat2/xNBA.git
synced 2024-11-29 12:49:49 +00:00
[librm] Add rm stack copying functions
This commit is contained in:
parent
2539f5fa4a
commit
aa28544373
@ -279,6 +279,9 @@ user_to_phys ( userptr_t buffer, off_t offset ) {
|
||||
return virt_to_phys ( ( void * ) buffer + offset );
|
||||
}
|
||||
|
||||
extern uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size );
|
||||
extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
|
||||
|
||||
/* TEXT16_CODE: declare a fragment of code that resides in .text16 */
|
||||
#define TEXT16_CODE( asm_code_str ) \
|
||||
".section \".text16\", \"ax\", @progbits\n\t" \
|
||||
|
45
src/arch/i386/transitions/librm_mgmt.c
Executable file
45
src/arch/i386/transitions/librm_mgmt.c
Executable file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* librm: a library for interfacing to real-mode code
|
||||
*
|
||||
* Michael Brown <mbrown@fensystems.co.uk>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <librm.h>
|
||||
|
||||
/*
|
||||
* This file provides functions for managing librm.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allocate space on the real-mode stack and copy data there from a
|
||||
* user buffer
|
||||
*
|
||||
* @v data User buffer
|
||||
* @v size Size of stack data
|
||||
* @ret sp New value of real-mode stack pointer
|
||||
*/
|
||||
uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) {
|
||||
userptr_t rm_stack;
|
||||
rm_sp -= size;
|
||||
rm_stack = real_to_user ( rm_ss, rm_sp );
|
||||
memcpy_user ( rm_stack, 0, data, 0, size );
|
||||
return rm_sp;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deallocate space on the real-mode stack, optionally copying back
|
||||
* data to a user buffer.
|
||||
*
|
||||
* @v data User buffer
|
||||
* @v size Size of stack data
|
||||
*/
|
||||
void remove_user_from_rm_stack ( userptr_t data, size_t size ) {
|
||||
if ( data ) {
|
||||
userptr_t rm_stack = real_to_user ( rm_ss, rm_sp );
|
||||
memcpy_user ( rm_stack, 0, data, 0, size );
|
||||
}
|
||||
rm_sp += size;
|
||||
};
|
Loading…
Reference in New Issue
Block a user