OpenVSA: Difference between revisions

From coreboot
Jump to navigation Jump to search
(Initial creation)
 
No edit summary
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
The current status of the OpenVSA is: '''''experimental'''''.  Please do not use OpenVSA in your system unless you have access to a low-level re-flashing tools.
'''VSA''', or '''Virtual System Architecture''' is a low-level software library included in the bootloader/BIOS for system using AMD Geode-series CPUs and companion chips.
 
AMD released VSA sources under the name '''geode-vsa''' in 2006 (licensed under the terms of the GNU LGPL)The original sources were hosted by the OLPC project, and can be pulled with git from <code>git://dev.laptop.org/geode-vsa</code>.  Updated sources are hosted by coreboot.org located in the [http://review.coreboot.org/gitweb?p=blobs.git;a=tree;f=cpu/amd/geode_lx;hb=HEAD blobs repository]. The '''OpenVSA''' sources include modified '''geode-vsa''' sources, as well as some new components also released under the GNU LGPL.


To obtain the OpenVSA sources, refer to [[download coreboot]].
The VSA code runs under x86 SMM (System Management Mode) which is like "real mode" with some extra opcodes, priviledges, and side-effects.


== Context ==
As originally published, the VSA code compiled and assembled with older, commercially unavailable versions of Microsoft tools.  The OpenVSA code has been modified in order to build under a GNU toolchain so that it may be maintained and enhanced by a wider group of users. It still requires MASM or a compatible assembler, such as [http://www.japheth.de/JWasm.html JWasm]. Because of this, it wasn't integrated in the coreboot build process yet.


VSA, or Virtual System Architecture is a low-level software library included in the bootloader/BIOS for system using AMD Geode-series CPUs and companion chips.
== Status ==


AMD released VSA sources under the GNU LGPL in 2006.  Those sources were hosted by the OLPC project, and can be pulled with git from <code>git://dev.laptop.org/geode-vsa</code>The OpenVSA sources include modified Geode VSA sources, as well as some new components also released under the GNU LGPL.
The current status of the OpenVSA is: '''''experimental'''''Please do not use OpenVSA in your system unless you have access to a low-level re-flashing tools.


The VSA code runs under x86 SMM (System Management Mode) which is like "real mode" with some extra opcodes, priviledges, and side-effects. 
== Download ==


As originally published, the VSA code compiled and assembled with older, commercially unavailable versions of Microsoft tools.  The OpenVSA code has been modified in order to build under a GNU toolchain so that it may be maintained and enhanced by a wider group of users.
Please refer to the [[AMD_Geode_Porting_Guide#Manual_build|AMD_Geode_Porting_Guide]].


== Differences Between VSA and OpenVSA ==
== Differences Between VSA and OpenVSA ==
Line 18: Line 20:


{|
{|
|-
|- bgcolor="#6699ff"
!Category
!Category
!VSA
!VSA
!OpenVSA
!OpenVSA
|-
 
|- bgcolor="#dddddd"
|Assembler
|Assembler
|MASM 6.11c or greater
|MASM 6.11c or greater
|GNU gas (part of binutils)
|GNU gas (part of binutils)
|-
 
|- bgcolor="#cccccc"
|Make
|Make
|NMAKE.EXE Version 1.40 or greater
|NMAKE.EXE Version 1.40 or greater
|GNU make
|GNU make
|-
 
|- bgcolor="#dddddd"
|C-compiler
|C-compiler
|MSVC Version 1.52
|MSVC Version 1.52
|GNU gcc
|GNU gcc
|-
 
|- bgcolor="#cccccc"
|Final binary output
|Final binary output
|exe2bin.exe
|exe2bin.exe
|GNU objcopy (part of binutils)
|GNU objcopy (part of binutils)
|-
 
|- bgcolor="#dddddd"
|Assembly syntax
|Assembly syntax
|Microsoft/Intel
|Microsoft/Intel
|GNU gas/AT&T
|GNU gas/AT&T
|-
 
|- bgcolor="#cccccc"
|Code Generation
|Code Generation
|16-bit, inherent to the toolchain commands used during build
|16-bit, inherent to the toolchain commands used during build
|16-bit assembly, generated by using <code>.code16</code> in assembly files; 32-bit from C, prefixes generated by using <code>.code16gcc</code> in C files
|16-bit assembly, generated by using <code>.code16</code> in assembly files; 32-bit from C, prefixes generated by using <code>.code16gcc</code> in C files
|-
 
|- bgcolor="#dddddd"
|Memory Model
|Memory Model
|"tiny": merges CS and DS, inherent to the toolchain commands used during build
|"tiny": merges CS and DS, inherent to the toolchain commands used during build
|"tiny" model accomplished with specific section names and linker script statements
|"tiny" model accomplished with specific section names and linker script statements
|-
 
|- bgcolor="#cccccc"
|SMM-only opcode assembly
|SMM-only opcode assembly
|MASM macros
|MASM macros
|Perl script <code>smimac.pl</code> pre-processes to constant-sequences
|Perl script <code>smimac.pl</code> pre-processes to constant-sequences
|-
 
|- bgcolor="#dddddd"
|Internal assembly functions: calling convention
|Internal assembly functions: calling convention
|custom/random, no apparent fixed pattern
|custom/random, no apparent fixed pattern
|unchanged
|unchanged
|-
 
|- bgcolor="#cccccc"
|Assembly functions called from C: calling convention
|Assembly functions called from C: calling convention
|Microsoft <code>pascal</code>
|Microsoft <code>pascal</code>
|GNU <code>__attribute__((fastcall))</code>
|GNU <code>__attribute__((fastcall))</code>
|-
 
|- bgcolor="#dddddd"
|C header file translation to assembly include
|C header file translation to assembly include
|h2inc.exe
|h2inc.exe
Line 169: Line 182:


TODO.
TODO.
{{PD-self}}

Latest revision as of 10:32, 7 February 2013

VSA, or Virtual System Architecture is a low-level software library included in the bootloader/BIOS for system using AMD Geode-series CPUs and companion chips.

AMD released VSA sources under the name geode-vsa in 2006 (licensed under the terms of the GNU LGPL). The original sources were hosted by the OLPC project, and can be pulled with git from git://dev.laptop.org/geode-vsa. Updated sources are hosted by coreboot.org located in the blobs repository. The OpenVSA sources include modified geode-vsa sources, as well as some new components also released under the GNU LGPL.

The VSA code runs under x86 SMM (System Management Mode) which is like "real mode" with some extra opcodes, priviledges, and side-effects.

As originally published, the VSA code compiled and assembled with older, commercially unavailable versions of Microsoft tools. The OpenVSA code has been modified in order to build under a GNU toolchain so that it may be maintained and enhanced by a wider group of users. It still requires MASM or a compatible assembler, such as JWasm. Because of this, it wasn't integrated in the coreboot build process yet.

Status

The current status of the OpenVSA is: experimental. Please do not use OpenVSA in your system unless you have access to a low-level re-flashing tools.

Download

Please refer to the AMD_Geode_Porting_Guide.

Differences Between VSA and OpenVSA

Summary

Category VSA OpenVSA
Assembler MASM 6.11c or greater GNU gas (part of binutils)
Make NMAKE.EXE Version 1.40 or greater GNU make
C-compiler MSVC Version 1.52 GNU gcc
Final binary output exe2bin.exe GNU objcopy (part of binutils)
Assembly syntax Microsoft/Intel GNU gas/AT&T
Code Generation 16-bit, inherent to the toolchain commands used during build 16-bit assembly, generated by using .code16 in assembly files; 32-bit from C, prefixes generated by using .code16gcc in C files
Memory Model "tiny": merges CS and DS, inherent to the toolchain commands used during build "tiny" model accomplished with specific section names and linker script statements
SMM-only opcode assembly MASM macros Perl script smimac.pl pre-processes to constant-sequences
Internal assembly functions: calling convention custom/random, no apparent fixed pattern unchanged
Assembly functions called from C: calling convention Microsoft pascal GNU __attribute__((fastcall))
C header file translation to assembly include h2inc.exe manual/static translation

Calling Conventions And Stack

VSA: MASM and Microsoft C

The original VSA sources used 16-bit MS PASCAL calling convention (__pascal):

  • stack parameter order: left-to-right
  • called function cleans up the stack
  • all parameters are pushed onto the stack
  • return values to 16 bits returned in AX
  • return values 17 to 32 bits returned in DX:AX
  • scratch registers AX, BX, CX, DX, ES
^           |<- 16 bits ->|
| higher
| address
| (pop)

             -------------
            | first param |
             -------------
                  ...
             -------------
            |  last param |   4(BP)
             -------------
            |  return IP  |   2(BP)
             -------------
            |   old BP    | <-- BP
             -------------
                (locals)     -2(BP)
             -------------
              (saved regs)
             -------------
            | (saved reg) | <-- SP
             -------------

| lower
| address
| (push)
v

OpenVSA: GNU

With GNU on the Intel 386, the fastcall attribute (__attribute__(fastcall)) calling convention:

  • stack parameter order: right-to-left
  • called function cleans up the stack
  • if the first one or two arguments are integers/pointers (<=32bit), they are passed via ECX and EDX
  • all other parameters are pushed onto the stack
  • return values to 32 bits are returned in EAX
  • scratch registers EAX, ECX, EDX
^           |<- 32 bits ->|
| higher
| address
| (pop)                      (uses              (no
                              frame)             frame)

             -------------
            | last param  |
             -------------
                  ...
             -------------
            |  3rd param  |   8(EBP)            4(ESP)
             -------------
            | return EIP  |                   <-- ESP
             -------------
            |  saved EBP  | <-- EBP
             -------------
                (locals)     -4(EBP)
             -------------
              (saved regs)
             -------------
              (saved reg)   <-- ESP
| lower
| address
| (push)
v

Notable C-Code Differences

Microsoft C appears to accept a statement like:

 ULONG Data;
 ...
 (UCHAR)Data = 0;

This is not a portable construction, GCC rejects is, so has been changed to:

 *((UCHAR *) &Data) = 0;

Feature Wish List

TODO.

Hacking Notes

TODO.


Public domain I, the copyright holder of this work, hereby release it into the public domain. This applies worldwide.

In case this is not legally possible:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.