Skip to content

Commit

Permalink
rmode: add real mode related files ...
Browse files Browse the repository at this point in the history
... and move _long_to_real() with a long_to_real() wrapper there

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Feb 12, 2021
1 parent f669534 commit 1caf010
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 7 deletions.
36 changes: 36 additions & 0 deletions arch/x86/real_mode_func.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright © 2020 Amazon.com, Inc. or its affiliates.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <console.h>
#include <ktf.h>
#include <lib.h>

extern void _long_to_real(void);

/* FIXME: add real mode calling functionality */
void long_to_real(void) {
dprintk("%s: Before call\n", __func__);
_long_to_real();
dprintk("%s: After call\n", __func__);
}
8 changes: 1 addition & 7 deletions common/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#include <perfmon/pfmlib.h>
#endif

extern void _long_to_real(void);

extern int usermode_call_asm(user_func_t fn, void *fn_arg, unsigned long ret2kern_sp,
unsigned long user_stack);

Expand All @@ -61,14 +59,10 @@ void __naked kernel_main(void) {
display_memory_map();
display_multiboot_mmap();

if (opt_debug) {
_long_to_real();
printk("\n After long_to_real\n");
}

#ifdef KTF_PMU
pfm_initialize();
#endif

test_main();

printk("All tasks done.\n");
Expand Down
34 changes: 34 additions & 0 deletions include/arch/x86/real_mode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright © 2020 Amazon.com, Inc. or its affiliates.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KTF_REAL_MODE_H
#define KTF_REAL_MODE_H

#ifndef __ASSEMBLY__

extern void long_to_real(void);

#endif /* __ASSEMBLY__ */

#endif /* KTF_REAL_MODE_H */
4 changes: 4 additions & 0 deletions tests/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
#include <console.h>
#include <ktf.h>
#include <real_mode.h>
#include <sched.h>

#ifdef KTF_UNIT_TEST
Expand Down Expand Up @@ -136,6 +137,9 @@ static int ktf_unit_tests(void) {
cpu_freq_expect("Prototyp Amazing Foo One @ 1GHz", 1000000000);
cpu_freq_expect("Prototyp Amazing Foo Two @ 1.00GHz", 1000000000);

printk("Long mode to real mode transition:\n");
long_to_real();

return 0;
}
#else
Expand Down

0 comments on commit 1caf010

Please sign in to comment.