This is "backport" of the work I did at illumos side and is essentially based on vidconsole implementation.
few notes:
the getchar() needs to translate special keys, I did left in the switch (in illumos code I was also translating arrow keys etc) even as it currently has only entry for esc key.
"box" bios codes are translated for putchar. the issue is, in EFI the character codes are multibyte and as ficl does not support multibyte chars, this translation is currently most reasonable. There is an catch tho - as in bios the box chars are upper half of the table and therefore are having "negative" values, this will bring in the signed versus unsigned char issue for putchar(). In this diff I did add cast to unsigned char for amd64 variant of ficl. This allows to use meaningful hex codes for bios box chars in putchar.
And final note is about HO() call added for mode command - to make mode switches more "clean".