Skip to content

Commit

Permalink
Preparing for publication
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex0vSky committed Oct 2, 2023
1 parent 009c12b commit 92dfadb
Show file tree
Hide file tree
Showing 29 changed files with 53 additions and 15 deletions.
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
# _TinyEhci_
[![asm](https://img.shields.io/badge/asm-x86-blue?logo=intel)](
https://en.wikipedia.org/wiki/Assembly_language
)

Tiny, less then 512 bytes, ehci(usb2) reading on bare-metal

## Features
Tricks to reduce all of them
Completely search process to find only certain stick in USB2 slot.
Tricks to reduce all of them and
detail in [explanation](https://alex0vsky.github.io/posts/TinyEhci#Explanation) text

## Requirements
Fasm, Qemu
Nasm, Qemu or Hadrware with supporting boot of Usb Legacy, something like HxD to write bootsector in usbstick

## Install
If wonna write bootsector in usbstick [install](https://alex0vsky.github.io/posts/TinyEhci#write_bootsector) some text...

## Usage
modify `include\paths.cmd`
build `bootsector.img` and run in *qemu* emulator
`step5_gh\build_and_run_nographic.bat`
or write
`bootsector.img` to *flash usb stick*, starting from first sector
Modify path to _qemu_ and _nasm_ in `include/paths.cmd`
Build `step5_gh/bootsector.img` and after, run in *qemu* emulator
`step5_gh/build_and_run_nographic.bat`
or write built `bootsector.img` to *flash usb stick*, starting from first sector
Then, need to switch on your BIOS to loading from USB, and enable "Legacy Usb" mode

## Tests
comming soon partially

## Build
- *.asm - callable code
- *.inc - defines, true/false, contants
- *.inl - inline code
- *.mac - macro with arguments
Just pass include path to nasm for compiling single `bootsector.asm`
File extension convention:
*.asm - callable code
*.inc - defines, true/false, contants
*.inl - inline code
*.mac - macro with arguments

## Contributing
Can ask questions. PRs are accepted. No requirements for contributing.

## Thanks
tatOs, kolibriOs
USB2 Standard group, tatOs, kolibriOs

## License
See the [LICENSE](https://github.com/Alex0vSky/TinyEhci/blob/main/LICENSE) file for license rights and limitations (MIT).
1 change: 1 addition & 0 deletions include/BootTime/adjustStack/ax0/belowThenBootsector.inl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; BootTime/adjustStack/ax0/belowThenBootsector.inl - stack setup, below the loaded bootsector (ax=0)

; The stack grows downwards, i.e. the next address used will be [sp - 2] (for 16 bits).
Expand Down
1 change: 1 addition & 0 deletions include/BootTime/ax0/adjustDsCs.inl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; BootTime/ax0/adjustDsCs.inl - configure segment registers "ds" and "cs" 16bit (ax=0), @insp smbmbr03.zip\SMBMBR.ASM

; zeros everywhere
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; BootTime/bootRecordFormat/afterPayload/pair_Bpb_UsbLegacySupport.inl - completion for BootTime/bootRecordFormat/beforePayload/pair_Bpb_UsbLegacySupport.inl

%ifndef def_$BootTime$bootRecordFormat$aft$UsbLegacySupport$_once
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; BootTime/bootRecordFormat/beforePayload/pair_Bpb_UsbLegacySupport.inl - on the hardware the flash drive is displayed as "USB FDD label"
; @insp \include\BootTime\bootRecordFormat\beforePayload\pair_Fat12BootRecord_kolibriOs.inl
; @insp https://infogalactic.com/info/BIOS_Parameter_Block
Expand Down
1 change: 1 addition & 0 deletions include/BootTime/markedSectorsAndFddSize.inl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; BootTime/markedSectorsAndFddSize.inl - stub which usually goes at the end of the bootsector, but the code used is also located in eight sectors

; Number of sectors for "recognizable" padding
Expand Down
1 change: 1 addition & 0 deletions include/dvc/Cpu/bigUnrealMode/trashFirstEntry.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Cpu/bigUnrealMode/trashFirstEntry.asm - working with Big Unreal Mode, the first record from the table (not used by the processor) is filled with garbage or random data
%ifndef def_dvc$Cpu$bigUnrealMode$trashFirstEntry$_once ; #pragma once
%define def_dvc$Cpu$bigUnrealMode$trashFirstEntry$_once
Expand Down
1 change: 1 addition & 0 deletions include/dvc/Cpu/bigUnrealMode/zeroidFirstEntry.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Cpu/bigUnrealMode/zeroidFirstEntry.asm - working with Big Unreal Mode, the first entry from the table (not used by the processor) is filled with zeros
%ifndef def_dvc$Cpu$bigUnrealMode$zeroidFirstEntry$_once ; #pragma once
%define def_dvc$Cpu$bigUnrealMode$zeroidFirstEntry$_once
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Pci/Usb/Ehci/asyncList/dataStruc/realModeAddr_segDs0/attachedSglQh/init.asm - creation of data structures by code in memory segment 0 pointed to by the "ds" register, one "Qh" connected to the existing one from the BIOS "Qh"
%ifndef def_dvc$Pci$Usb$Ehci$asyncList$dataStruc$realModeAddr_segDs0$attachedSglQh$init$_once ; #pragma once
%define def_dvc$Pci$Usb$Ehci$asyncList$dataStruc$realModeAddr_segDs0$attachedSglQh$init$_once
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Pci/Usb/Ehci/asyncList/dataStruc/realModeAddr_segDs0/attachedSglQh/setHorizLinkPtr.asm - creation of data structures by code in memory segment 0 pointed to by the "ds" register, one "Qh" connected to the existing one from the BIOS "Qh"
%ifndef def_dvc$Pci$Usb$Ehci$asyncList$dataStruc$realModeAddr_segDs0$attachedSglQh$setHorizLinkPtr$_once ; #pragma once
%define def_dvc$Pci$Usb$Ehci$asyncList$dataStruc$realModeAddr_segDs0$attachedSglQh$setHorizLinkPtr$_once
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Pci/Usb/Ehci/asyncList/directAcsBlkCmd/common.inc - constants
%ifndef def_dvc$Pci$Usb$Ehci$asyncList$directAcsBlkCmd$common$_once ; #pragma once
%define def_dvc$Pci$Usb$Ehci$asyncList$directAcsBlkCmd$common$_once
Expand Down
1 change: 1 addition & 0 deletions include/dvc/Pci/Usb/Ehci/asyncList/stdDvcReq/common.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Pci/Usb/Ehci/asyncList/stdDvcReq/common.inc - constants
%ifndef def_dvc$Pci$Usb$Ehci$asyncList$stdDvcReq$common$_once ; #pragma once
%define def_dvc$Pci$Usb$Ehci$asyncList$stdDvcReq$common$_once
Expand Down
1 change: 1 addition & 0 deletions include/dvc/Pci/Usb/Ehci/common.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Pci/Usb/Ehci/common.inc - working with USB type Ehci, constants
; description of field bits in comments from dvc\Pci\Usb\Ehci\directHardware\diag.asm

Expand Down
1 change: 1 addition & 0 deletions include/dvc/Pci/Usb/Ehci/find/pio/callAfterFound.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Pci/Usb/Ehci/find/pio/callAfterFound.asm - calling a certain function after finding the "EHCI" controller
%ifndef def_dvc$Pci$Usb$Ehci$find$pio$callAfterFound$_once ; #pragma once
%define def_dvc$Pci$Usb$Ehci$find$pio$callAfterFound$_once
Expand Down
1 change: 1 addition & 0 deletions include/dvc/Pci/Usb/Ehci/find/pio/common.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Pci/Usb/Ehci/find/pio/common.inc - constants
%ifndef def_dvc$Pci$Usb$Ehci$find$pio$common$_once ; #pragma once
%define def_dvc$Pci$Usb$Ehci$find$pio$common$_once
Expand Down
1 change: 1 addition & 0 deletions include/dvc/Pci/Usb/Ehci/macro.mac
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Pci/Usb/Ehci/macro.mac - work with USB type Ehci, macros

; Macro for calculating the index of the "PCI" port from "BDF" when the offset is known in advance
Expand Down
1 change: 1 addition & 0 deletions include/dvc/Pci/Usb/Ehci/scanDeviceAddrAndReadX.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Pci/Usb/Ehci/scanDeviceAddrAndReadX.asm - scan "DeviceAddr" of the "EHCI" controller and read sectors from there
%ifndef def_dvc$Pci$Usb$Ehci$scanDeviceAddrAndReadX$_once ; #pragma once
%define def_dvc$Pci$Usb$Ehci$scanDeviceAddrAndReadX$_once
Expand Down
1 change: 1 addition & 0 deletions include/dvc/Vga/TextMode.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Vga/TextMode.inc - constants for the terminal in text mode (mode 03, CGA-compatible text mode)

; Note: VGA frame buffer address range 0xA0000 to 0xBFFFF
Expand Down
1 change: 1 addition & 0 deletions include/dvc/Vga/standalonePrintHexDword.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; dvc/Vga/standalonePrintHexDword.asm - outputting a double word in hexadecimal format to the screen, a self-contained option. The goal is minimum code
%ifndef def_dvc$Vga$standalonePrintHexDword$_once ; #pragma once
%define def_dvc$Vga$standalonePrintHexDword$_once
Expand Down
1 change: 1 addition & 0 deletions include/io/ConfiguredTty.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; io/ConfiguredTty.asm - main file including code for text video mode functionality
%ifndef def_$io$ConfiguredTty$_once ; #pragma once
%define def_$io$ConfiguredTty$_once
Expand Down
1 change: 1 addition & 0 deletions include/io/OvrTty.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; io/OvrTty.asm - base for output to video terminal in text mode, {T}ele{TY}pe

; Only if the self-explanatory output "Dword" is not specified
Expand Down
1 change: 1 addition & 0 deletions include/io/Tty/PrintChar/Bios.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; io/Tty/PrintChar/Bios.asm - output to a video terminal in text mode using BIOS methods
%ifndef def_io$Tty$PrintChar$Bios$_once ; #pragma once
%define def_io$Tty$PrintChar$Bios$_once
Expand Down
1 change: 1 addition & 0 deletions include/io/Tty/UsingPrintChar.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; io/Tty/UsingPrintChar.asm - a set of functions using the "PrintChar" implementation for displaying on the screen

%ifdef def_$io$Tty$UsingPrintChar$bAllow_hexByte
Expand Down
1 change: 1 addition & 0 deletions include/paths.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@REM Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
REM paths.cmd - Main config
REM Double quotes are prohibited because they complicate calling invis via 'mshta vbscript:Execute("CreateObject(""Wscript.Shell"").Run ...'
set ffnAssemblerExe=C:\Prj\_Tools\baremetal\nasm-2.16.01\nasm.exe
Expand Down
1 change: 1 addition & 0 deletions include/util/bswap.mac
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; util/bswap.mac - reverses the byte order
%ifndef def_util$bswap$_once ; #pragma once
%define def_util$bswap$_once
Expand Down
3 changes: 2 additions & 1 deletion step5_gh/bootsector.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; C:\Prj\sysbare\HomoT\step5_gh\bootsector.asm - main
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; step5_gh\bootsector.asm - main
BITS 16
ORG 0x7C00
SECTION .bootsector
Expand Down
1 change: 1 addition & 0 deletions step5_gh/build_and_run_nographic.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@REM Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
@echo off & REM ./step5_gh/build_and_run_nographic.bat - builder

REM Config
Expand Down
3 changes: 2 additions & 1 deletion step5_gh/config.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; C:\Prj\HomoT\step3_usb\config.inc - configuration
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; step5_gh\config.inc - configuration

; Screen display method.
; use BIOS interrupts.
Expand Down
3 changes: 2 additions & 1 deletion step5_gh/readViaOneQhAndJmp.inl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; C:\Prj\sysbare\HomoT\step5_gh\readViaOneQhAndJmp.inl - reading sectors using one "Qh" and "jmp" there when a signature is found, inserted
; Copyright 2023 Alex0vSky (https://github.com/Alex0vSky)
; step5_gh\readViaOneQhAndJmp.inl - reading sectors using one "Qh" and "jmp" there when a signature is found, inserted

; -------------------------------------------------------------------------------------------------
; -//-
Expand Down

0 comments on commit 92dfadb

Please sign in to comment.