Discussion:
A20 desperation mode
(too old to reply)
muta...@gmail.com
2021-07-12 13:45:33 UTC
Permalink
There was once a situation, using Rufus I think,
where the A20 line wasn't being enabled by any
of the techniques.

It occurs to me that in that situation I can have
a "desperation mode" where I instead set up
1 MiB regions of free memory, which should
satisfy quite a lot of applications.

So 1-2 MiB would be skipped. 3-4 MiB would
be skipped. etc.

BFN. Paul.
muta...@gmail.com
2021-07-12 21:51:40 UTC
Permalink
Post by ***@gmail.com
It occurs to me that in that situation I can have
a "desperation mode" where I instead set up
1 MiB regions of free memory, which should
satisfy quite a lot of applications.
Actually I can do all that while in protected mode.

I start with memory below 1 MiB being made available
to PDOS/386, and then attempt to enable A20 via the
official BIOS interrupt.

Then if I detect that A20 is not enabled, I can present
the user with options:

1. Manipulate hardware to try to enable A20 (your funeral).

2. Enable "desperation mode" (technically sound).

3. Enable desperation mode and then email Jens to carpet
bomb Taiwan for making you lose half your memory and
fragmenting what remains into 1 MiB chunks so that you
can no longer run a 3 MB executable like gccwin (recommended).

BFN. Paul.
muta...@gmail.com
2021-07-13 01:05:24 UTC
Permalink
Post by ***@gmail.com
3. Enable desperation mode and then email Jens to carpet
bomb Taiwan for making you lose half your memory and
fragmenting what remains into 1 MiB chunks so that you
can no longer run a 3 MB executable like gccwin (recommended).
Actually, does A20 constrain physical or virtual addresses?

If the former, I could enable VM, have a return to flat memory,
at the expense of just losing half the memory. ie I can still
run 3 MB executables.

BFN. Paul.
Alexei A. Frounze
2021-07-13 02:11:40 UTC
Permalink
Post by ***@gmail.com
Post by ***@gmail.com
3. Enable desperation mode and then email Jens to carpet
bomb Taiwan for making you lose half your memory and
fragmenting what remains into 1 MiB chunks so that you
can no longer run a 3 MB executable like gccwin (recommended).
Actually, does A20 constrain physical or virtual addresses?
If the former, I could enable VM, have a return to flat memory,
at the expense of just losing half the memory. ie I can still
run 3 MB executables.
Physical. If you use page translation, you can hide the discontiguity/holes.

Alex
James Harris
2021-07-18 22:13:46 UTC
Permalink
Post by ***@gmail.com
Post by ***@gmail.com
It occurs to me that in that situation I can have
a "desperation mode" where I instead set up
1 MiB regions of free memory, which should
satisfy quite a lot of applications.
Actually I can do all that while in protected mode.
I start with memory below 1 MiB being made available
to PDOS/386, and then attempt to enable A20 via the
official BIOS interrupt.
A20 has to be enabled before entering PMode. Processor operation is
undefined otherwise.

Rod checked up and found that to be true for both Intel and AMD. See his
various comments in

https://groups.google.com/g/alt.os.development/c/uRhADf8_nS8/m/aYn-cJ7klicJ
Post by ***@gmail.com
Then if I detect that A20 is not enabled, I can present
1. Manipulate hardware to try to enable A20 (your funeral).
2. Enable "desperation mode" (technically sound).
3. Enable desperation mode and then email Jens to carpet
bomb Taiwan for making you lose half your memory and
fragmenting what remains into 1 MiB chunks so that you
can no longer run a 3 MB executable like gccwin (recommended).
If you want processors to perform to spec you have to ensure A20 is
enabled before entering PMode.

As for how, I think Rod already pointed you to this table

http://aodfaq.wikidot.com/mc-a20-controls

Contrast the "KBC Method" column with that for "BIOS Control".
--
James Harris
Joe Monk
2021-07-19 17:01:13 UTC
Permalink
Post by James Harris
A20 has to be enabled before entering PMode. Processor operation is
undefined otherwise.
If you want processors to perform to spec you have to ensure A20 is
enabled before entering PMode.
All modern PC's start with A20 enabled.

As you can see from the provided example: http://www.scs.stanford.edu/05au-cs240c/lab/i386/s10_05.htm there is no check to see if A20 is enabled before going to protected mode.

Joe
James Harris
2021-07-20 11:42:04 UTC
Permalink
Post by Joe Monk
Post by James Harris
A20 has to be enabled before entering PMode. Processor operation is
undefined otherwise.
If you want processors to perform to spec you have to ensure A20 is
enabled before entering PMode.
All modern PC's start with A20 enabled.
Er, how are you defining "modern"?

If the code is started in 32-bit or 64-bit mode I would agree that
there's no need to run any A20-enable routine.

But if one is writing 16-bit code there are two choices:

1) Assume a 'modern' PC.

2) Check that it's modern enough.

The assumption is unnecessary as checking is easy. And the check is
probably best as a check for A20 state anyway.

Furthermore, - as you may have noticed - Paul is targetting PCs so old
they would not fit your idea of modern.
Post by Joe Monk
As you can see from the provided example: http://www.scs.stanford.edu/05au-cs240c/lab/i386/s10_05.htm there is no check to see if A20 is enabled before going to protected mode.
I wouldn't expect code in the 80386 manual to do such a check as the A20
Gate was part of the PC architecture, not part of the Intel CPU spec.
--
James Harris
wolfgang kern
2021-07-20 14:04:07 UTC
Permalink
On 20.07.2021 13:42, James Harris wrote:
...
Post by James Harris
Post by Joe Monk
All modern PC's start with A20 enabled.
Er, how are you defining "modern"?
all my machines don't even have an A20 gate anymore, since 2010.
but I kept the few bytes to check ffff:0010 isn't equal to 0:0.
__
wolfgang
James Harris
2021-07-20 17:56:01 UTC
Permalink
Post by wolfgang kern
...
Post by James Harris
Post by Joe Monk
All modern PC's start with A20 enabled.
Er, how are you defining "modern"?
all my machines don't even have an A20 gate anymore, since 2010.
All your machines are chosen to be of the same kind, aren't they? IIRC
you were buying and selling machines which were specifically intended to
be the same as each other so you could rely on their hardware being
compatible.
Post by wolfgang kern
but I kept the few bytes to check ffff:0010 isn't equal to 0:0.
Very sensible. It's virtually cost-free assurance.
--
James Harris
Joe Monk
2021-07-20 23:32:49 UTC
Permalink
The Intel programming guide since 2013 has said that the A20M# pin may not be present.

Joe
wolfgang kern
2021-07-21 06:02:34 UTC
Permalink
On 20.07.2021 19:56, James Harris wrote:
...
Post by James Harris
Post by wolfgang kern
Post by James Harris
Post by Joe Monk
All modern PC's start with A20 enabled.
Er, how are you defining "modern"?
all my machines don't even have an A20 gate anymore, since 2010.
All your machines are chosen to be of the same kind, aren't they? IIRC
you were buying and selling machines which were specifically intended to
be the same as each other so you could rely on their hardware being
compatible.
yes all from one vendor but different generations 2010/2014/2018.
there were a few software things to modify for a hardware change.
Post by James Harris
Post by wolfgang kern
but I kept the few bytes to check ffff:0010 isn't equal to 0:0.
Very sensible. It's virtually cost-free assurance.
it was cheaper to keep it :)
; push -1
; pop es I need this four anyway
; push 0 done during boot once
; pop ds
66 A1 00 00 mov eax,[0000]
36 66 3B 06 10 00 cmp eax,[es:0010]
74 xx JZ ... ;A20 failed
__
wolfgang
James Harris
2021-07-25 15:59:04 UTC
Permalink
...
Post by wolfgang kern
Post by James Harris
Post by wolfgang kern
all my machines don't even have an A20 gate anymore, since 2010.
...
Post by wolfgang kern
Post by James Harris
Post by wolfgang kern
but I kept the few bytes to check ffff:0010 isn't equal to 0:0.
Very sensible. It's virtually cost-free assurance.
it was cheaper to keep it :)
; push -1
; pop es          I need this four anyway
; push 0          done during boot once
; pop ds
66 A1 00 00       mov eax,[0000]
36 66 3B 06 10 00 cmp eax,[es:0010]
74 xx             JZ ... ;A20 failed
Presumably you know those locations cannot be equal. I have code which
does something similar to yours

mov ax, [A20_TEST_WORD]
cmp ax, [es: A20_TEST_WORD + 16]
jne .enabled

but in case the values just happen to be the same I follow it with

not ax ;Set a different value
mov [A20_TEST_WORD], ax
cmp ax, [es: A20_TEST_WORD + 16]
not ax ;Get back old value (without changing flags)
mov [A20_TEST_WORD], ax ;Restore memory (without changing flags)
jne .enabled ;Branch on result of the compare instruction


which I expect you regard as bloat! :-)
--
James Harris
wolfgang kern
2021-07-26 00:36:48 UTC
Permalink
Post by James Harris
Post by wolfgang kern
Post by James Harris
Post by wolfgang kern
all my machines don't even have an A20 gate anymore, since 2010.
but I kept the few bytes to check ffff:0010 isn't equal to 0:0.
Very sensible. It's virtually cost-free assurance.
it was cheaper to keep it :)
; push -1
; pop es          I need this four anyway
; push 0          done during boot once
; pop ds
66 A1 00 00       mov eax,[0000]
36 66 3B 06 10 00 cmp eax,[es:0010]
74 xx             JZ ... ;A20 failed
Presumably you know those locations cannot be equal. I have code which
does something similar to yours
  mov ax, [A20_TEST_WORD]
  cmp ax, [es: A20_TEST_WORD + 16]
  jne .enabled
but in case the values just happen to be the same I follow it with
  not ax                   ;Set a different value
  mov [A20_TEST_WORD], ax
  cmp ax, [es: A20_TEST_WORD + 16]
  not ax                   ;Get back old value (without changing flags)
  mov [A20_TEST_WORD], ax  ;Restore memory (without changing flags)
  jne .enabled             ;Branch on result of the compare instruction
which I expect you regard as bloat! :-)
I may not see it as bloat because 16 bits could really be equal
so I call it James-styled aka double featured as usual :)
__
wolfgang

Loading...