Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d98755374f | ||
|
|
3a29c4395c | ||
|
|
25382c1e3c | ||
|
|
060ec1a5d0 | ||
|
|
882f1f0242 | ||
|
|
02070aa233 | ||
|
|
d0244f1513 | ||
|
|
44465b3cc2 | ||
|
|
1df9d8496d | ||
|
|
7917972a37 | ||
|
|
8334324d9c | ||
|
|
2757ea7d3e | ||
|
|
bf8ae67dbf | ||
|
|
69bd99e991 | ||
|
|
3bde56821f | ||
|
|
2c22604f39 | ||
|
|
de952921ee | ||
|
|
7f44db1b7f |
No files matched your search
@@ -0,0 +1,54 @@
|
||||
# =============================================================================
|
||||
# Apps
|
||||
# User-facing applications, games, multimedia, UI and desktop resources
|
||||
# =============================================================================
|
||||
|
||||
^programs/(cmm|demos|emulator|games|media|other)/.* @KolibriOS/apps
|
||||
^contrib/(games|media|other)/.* @KolibriOS/apps
|
||||
^skins/.* @KolibriOS/apps
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# System
|
||||
# Kernel, drivers, filesystems, SDK, libraries, toolchain and system utilities
|
||||
# =============================================================================
|
||||
|
||||
^kernel/.* @KolibriOS/system
|
||||
^drivers/.* @KolibriOS/system
|
||||
|
||||
^programs/(bcc32|develop|fs|hd_load|system|testing)/.* @KolibriOS/system
|
||||
^contrib/(C_Layer|sdk|toolchain)/.* @KolibriOS/system
|
||||
|
||||
# Shared system/API includes in programs/
|
||||
^programs/[^/]+\\.inc$ @KolibriOS/system
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Network
|
||||
# Network stack, network drivers, protocols, libraries and network applications
|
||||
# =============================================================================
|
||||
|
||||
^kernel/trunk/network/.* @KolibriOS/network
|
||||
|
||||
^drivers/ethernet/.* @KolibriOS/network
|
||||
^drivers/(mii|netdrv)\\.inc$ @KolibriOS/network
|
||||
|
||||
^programs/network/.* @KolibriOS/network
|
||||
^programs/network\\.inc$ @KolibriOS/network
|
||||
|
||||
^programs/develop/libraries/(http|network|kos_mbedtls)/.* @KolibriOS/network
|
||||
|
||||
^contrib/network/.* @KolibriOS/network
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# DevOps
|
||||
# CI/CD, repository infrastructure, build system and autobuild configuration
|
||||
# =============================================================================
|
||||
|
||||
^\\.gitea/.* @KolibriOS/devops
|
||||
^_tools/.* @KolibriOS/devops
|
||||
|
||||
^\\.gitmodules$ @KolibriOS/devops
|
||||
^build\\.txt$ @KolibriOS/devops
|
||||
^tup\\.config\\.template$ @KolibriOS/devops
|
||||
@@ -19,3 +19,38 @@
|
||||
owner: "{{ storage_user }}"
|
||||
group: "{{ storage_user }}"
|
||||
mode: preserve
|
||||
|
||||
# per-program binaries browsable at <version>/<lang>/data/, like on the old builds server
|
||||
- name: Creating build tree folders
|
||||
ansible.builtin.file:
|
||||
path: "{{ storage_path }}/{{ version }}/{{ item | basename | regex_replace('\\.tar\\.gz$', '') }}/data"
|
||||
state: directory
|
||||
owner: "{{ storage_user }}"
|
||||
group: "{{ storage_user }}"
|
||||
mode: '0755'
|
||||
with_fileglob: "{{ tree_artifact_path }}/*.tar.gz"
|
||||
|
||||
- name: Unpacking build trees
|
||||
ansible.builtin.unarchive:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ storage_path }}/{{ version }}/{{ item | basename | regex_replace('\\.tar\\.gz$', '') }}/data"
|
||||
owner: "{{ storage_user }}"
|
||||
group: "{{ storage_user }}"
|
||||
with_fileglob: "{{ tree_artifact_path }}/*.tar.gz"
|
||||
|
||||
# stable URL for the newest build: <storage_path>/latest/<lang>/...
|
||||
- name: Updating latest symlink
|
||||
ansible.builtin.file:
|
||||
src: "{{ version }}"
|
||||
dest: "{{ storage_path }}/latest"
|
||||
state: link
|
||||
force: true
|
||||
owner: "{{ storage_user }}"
|
||||
group: "{{ storage_user }}"
|
||||
|
||||
# emulators hardcode <site root>/<lang>/data/data/kolibri.img; storage_path is the ci folder, one level under the site root
|
||||
- name: Sending bare images to stable emulator paths
|
||||
ansible.builtin.copy:
|
||||
src: "{{ stable_artifact_path }}/"
|
||||
dest: "{{ storage_path }}/../"
|
||||
mode: preserve
|
||||
@@ -162,12 +162,13 @@ jobs:
|
||||
tup init
|
||||
tup variant ${{ matrix.lang }}.config
|
||||
|
||||
# build the image for language variant
|
||||
# build the image for language variant; keep the tup log for publishing
|
||||
- name: Build KolibriOS
|
||||
run: |
|
||||
set -o pipefail
|
||||
export PATH=/home/autobuild/tools/win32/bin:$PATH
|
||||
source kos32-export-env-vars ${{ gitea.workspace }}
|
||||
tup build-${{ matrix.lang }}
|
||||
tup build-${{ matrix.lang }} 2>&1 | tee build.log
|
||||
|
||||
# stamp the cache with its commit so later builds diff against it
|
||||
- name: Record cache base commit
|
||||
@@ -181,15 +182,26 @@ jobs:
|
||||
id: vars
|
||||
run: echo "descr=$(git describe --tags)" >> $GITEA_OUTPUT
|
||||
|
||||
# rename build outputs to their final names so artifacts are bare files
|
||||
- name: Rename images
|
||||
# stage build outputs under their final names, plus distribution kit and checksums
|
||||
- name: Prepare artifacts
|
||||
run: |
|
||||
set -e
|
||||
BASE="kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}"
|
||||
for ext in img iso raw; do
|
||||
cp "build-${{ matrix.lang }}/data/kolibri.$ext" \
|
||||
"kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.$ext"
|
||||
cp "build-${{ matrix.lang }}/data/kolibri.$ext" "$BASE.$ext"
|
||||
done
|
||||
# zip: distr targets Windows/DOS users, Explorer opens it natively
|
||||
(cd "build-${{ matrix.lang }}/data" && zip -r -9 -q "${{ gitea.workspace }}/$BASE.distr.zip" distribution_kit)
|
||||
# whole build tree for per-program downloads; the big images ship separately
|
||||
tar -C "build-${{ matrix.lang }}" \
|
||||
--exclude './data/kolibri.iso' \
|
||||
--exclude './data/kolibri.raw' \
|
||||
--exclude './data/distribution_kit' \
|
||||
-czf "$BASE.tree.tar.gz" .
|
||||
sha256sum "$BASE".img "$BASE".iso "$BASE".raw "$BASE".distr.zip > "$BASE.sha256sums.txt"
|
||||
mv build.log "$BASE.build.log"
|
||||
|
||||
#publish the three images; longer retention for the floppy image.
|
||||
# publish the images; longer retention for the floppy image
|
||||
- name: Upload floppy image
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
@@ -211,6 +223,34 @@ jobs:
|
||||
path: kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.raw
|
||||
retention-days: 15
|
||||
|
||||
- name: Upload distribution kit
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.distr.zip
|
||||
path: kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.distr.zip
|
||||
retention-days: 30
|
||||
|
||||
- name: Upload checksums
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.sha256sums.txt
|
||||
path: kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.sha256sums.txt
|
||||
retention-days: 90
|
||||
|
||||
- name: Upload build log
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.build.log
|
||||
path: kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.build.log
|
||||
retention-days: 90
|
||||
|
||||
- name: Upload build tree
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.tree.tar.gz
|
||||
path: kolibrios-${{ steps.vars.outputs.descr }}-${{ matrix.lang }}.tree.tar.gz
|
||||
retention-days: 15
|
||||
|
||||
deploy:
|
||||
name: "Publish Images"
|
||||
runs-on: ubuntu-latest
|
||||
@@ -235,31 +275,50 @@ jobs:
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
rm -rf ./norm-artifacts
|
||||
mkdir -p ./norm-artifacts
|
||||
rm -rf ./norm-artifacts ./stable-artifacts ./tree-artifacts
|
||||
mkdir -p ./norm-artifacts ./stable-artifacts ./tree-artifacts
|
||||
|
||||
find ./artifacts -type f \( \
|
||||
-name 'kolibrios-*.img' -o \
|
||||
-name 'kolibrios-*.iso' -o \
|
||||
-name 'kolibrios-*.raw' \
|
||||
\) | while read -r file; do
|
||||
fname="$(basename "$file")" # kolibrios-<descr>-<lang>.<ext>
|
||||
name_without_ext="${fname%.*}"
|
||||
lang="${name_without_ext##*-}"
|
||||
find ./artifacts -type f -name 'kolibrios-*' | while read -r file; do
|
||||
fname="$(basename "$file")" # kolibrios-<descr>-<lang>.<suffix>
|
||||
case "$fname" in
|
||||
*.tree.tar.gz) stem="${fname%.tree.tar.gz}";;
|
||||
*.distr.zip) stem="${fname%.distr.zip}";;
|
||||
*.sha256sums.txt) stem="${fname%.sha256sums.txt}";;
|
||||
*.build.log) stem="${fname%.build.log}";;
|
||||
*.img) stem="${fname%.img}";;
|
||||
*.iso) stem="${fname%.iso}";;
|
||||
*.raw) stem="${fname%.raw}";;
|
||||
*) continue;;
|
||||
esac
|
||||
lang="${stem##*-}" # <lang> has no dashes, <descr> may
|
||||
|
||||
mkdir -p "./norm-artifacts/$lang"
|
||||
cp "$file" "./norm-artifacts/$lang/$fname"
|
||||
case "$fname" in
|
||||
*.tree.tar.gz)
|
||||
# unpacked on the server into <version>/<lang>/data/ for per-program downloads
|
||||
cp "$file" "./tree-artifacts/$lang.tar.gz";;
|
||||
*.sha256sums.txt)
|
||||
cp "$file" "./norm-artifacts/$lang/sha256sums.txt";;
|
||||
*.build.log)
|
||||
cp "$file" "./norm-artifacts/$lang/build.log";;
|
||||
*.img)
|
||||
cp "$file" "./norm-artifacts/$lang/$fname"
|
||||
# emulators (e.g. v86) hardcode <lang>/data/data/kolibri.img at the site root
|
||||
mkdir -p "./stable-artifacts/$lang/data/data"
|
||||
cp "$file" "./stable-artifacts/$lang/data/data/kolibri.img";;
|
||||
*)
|
||||
cp "$file" "./norm-artifacts/$lang/$fname";;
|
||||
esac
|
||||
done
|
||||
|
||||
# derive the version (git describe) from an artifact name:
|
||||
# kolibrios-<descr>-<lang>.<ext> -> <descr>
|
||||
sample="$(find ./norm-artifacts -type f -name 'kolibrios-*' | head -n1)"
|
||||
# derive the version (git describe) from an artifact name: kolibrios-<descr>-<lang>.iso -> <descr>
|
||||
sample="$(find ./norm-artifacts -type f -name 'kolibrios-*.iso' | head -n1)"
|
||||
base="$(basename "${sample%.*}")" # kolibrios-<descr>-<lang>
|
||||
version="${base%-*}" # kolibrios-<descr>
|
||||
version="${version#kolibrios-}" # <descr>
|
||||
echo "version=$version" >> $GITEA_OUTPUT
|
||||
|
||||
find ./norm-artifacts -type f -print
|
||||
find ./norm-artifacts ./stable-artifacts ./tree-artifacts -type f -print
|
||||
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
@@ -285,4 +344,6 @@ jobs:
|
||||
-e "storage_path=${{ secrets.STORAGE_PATH }}" \
|
||||
-e "version=${{ steps.normalize.outputs.version }}" \
|
||||
-e "artifact_path=${{ gitea.workspace }}/norm-artifacts" \
|
||||
-e "stable_artifact_path=${{ gitea.workspace }}/stable-artifacts" \
|
||||
-e "tree_artifact_path=${{ gitea.workspace }}/tree-artifacts" \
|
||||
-v
|
||||
@@ -34,11 +34,10 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
token: ${{ secrets.BOT_TOKEN }}
|
||||
|
||||
- name: Bump ${{ matrix.name }} and open PR
|
||||
env:
|
||||
TOKEN: ${{ secrets.BOT_TOKEN }}
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
API: ${{ github.api_url }}
|
||||
REPO: ${{ github.repository }}
|
||||
NAME: ${{ matrix.name }}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
branch = main
|
||||
[submodule "programs/develop/oberon07"]
|
||||
path = programs/develop/oberon07
|
||||
url = https://github.com/AntKrotov/oberon-07-compiler.git
|
||||
url = https://git.kolibrios.org/KolibriOS/oberon-07-compiler.git
|
||||
branch = master
|
||||
[submodule "programs/cmm"]
|
||||
path = programs/cmm
|
||||
|
||||
@@ -573,6 +573,7 @@ tup.append_table(img_files, {
|
||||
{"DRIVERS/UHCI.SYS", VAR_DRVS .. "/usb/uhci.sys"},
|
||||
{"DRIVERS/OHCI.SYS", VAR_DRVS .. "/usb/ohci.sys"},
|
||||
{"DRIVERS/EHCI.SYS", VAR_DRVS .. "/usb/ehci.sys"},
|
||||
{"DRIVERS/XHCI.SYS", VAR_DRVS .. "/usb/xhci/xhci.sys"},
|
||||
{"DRIVERS/USBHID.SYS", VAR_DRVS .. "/usb/usbhid/usbhid.sys"},
|
||||
{"DRIVERS/USBFTDI.SYS", VAR_DRVS .. "/usb/usbftdi/usbftdi.sys"},
|
||||
{"DRIVERS/USBOTHER.SYS",VAR_DRVS .. "/usb/usbother/usbother.sys"},
|
||||
|
||||
@@ -0,0 +1,530 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2026. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; bcm57xx.inc - Broadcom NetXtreme register definitions ;;
|
||||
;; ;;
|
||||
;; Register names and values follow OpenBSD's if_bgereg.h ;;
|
||||
;; (Bill Paul / Wind River) with the BGE_ prefix dropped. ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; PCI configuration space (vendor specific part)
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
PCI_CMD_PIO = 0x0001
|
||||
PCI_CMD_MMIO = 0x0002
|
||||
PCI_CMD_MASTER = 0x0004
|
||||
|
||||
PCI_CACHESZ = 0x0c ; cacheline size / latency
|
||||
PCI_PWRMGMT_CMD = 0x4c ; PMCSR (fixed on all bge)
|
||||
PCI_PWR_STATE_MASK = 0x0003
|
||||
PCI_PWR_PME_ENABLE = 0x0100
|
||||
|
||||
PCI_MISC_CTL = 0x68
|
||||
PCI_DMA_RW_CTL = 0x6c
|
||||
PCI_PCISTATE = 0x70
|
||||
PCI_CLKCTL = 0x74
|
||||
PCI_REG_BASEADDR = 0x78 ; indirect CSR window
|
||||
PCI_MEMWIN_BASEADDR = 0x7c ; NIC memory window
|
||||
PCI_REG_DATA = 0x80
|
||||
PCI_MEMWIN_DATA = 0x84
|
||||
PCI_PRODID_ASICREV = 0xbc
|
||||
|
||||
; PCI misc host control bits
|
||||
PCIMISCCTL_CLEAR_INTA = 0x00000001
|
||||
PCIMISCCTL_MASK_PCI_INTR = 0x00000002
|
||||
PCIMISCCTL_ENDIAN_BYTESWAP = 0x00000004
|
||||
PCIMISCCTL_ENDIAN_WORDSWAP = 0x00000008
|
||||
PCIMISCCTL_PCISTATE_RW = 0x00000010
|
||||
PCIMISCCTL_CLOCKCTL_RW = 0x00000020
|
||||
PCIMISCCTL_REG_WORDSWAP = 0x00000040
|
||||
PCIMISCCTL_INDIRECT_ACCESS = 0x00000080
|
||||
PCIMISCCTL_TAGGED_STATUS = 0x00000200
|
||||
PCIMISCCTL_ASICREV_SHIFT = 16
|
||||
|
||||
; Value kept in PCI_MISC_CTL for the whole driver lifetime.
|
||||
; MASK_PCI_INTR is cleared again once the rings are live.
|
||||
BGE_INIT = PCIMISCCTL_CLEAR_INTA \
|
||||
or PCIMISCCTL_MASK_PCI_INTR \
|
||||
or PCIMISCCTL_INDIRECT_ACCESS \
|
||||
or PCIMISCCTL_ENDIAN_WORDSWAP \
|
||||
or PCIMISCCTL_PCISTATE_RW \
|
||||
or PCIMISCCTL_CLOCKCTL_RW
|
||||
|
||||
; PCI DMA read/write control
|
||||
PCIDMARWCTL_USE_MRM = 0x00400000
|
||||
PCIDMARWCTL_ASRT_ALL_BE = 0x00800000
|
||||
PCIDMARWCTL_DEFAULT = 0x763f0000 ; RD/WR cmd + watermarks
|
||||
|
||||
; PCI state
|
||||
PCISTATE_INTR_NOT_ACTIVE = 0x00000002
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; Memory mapped registers (BAR0)
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
; --- Mailboxes (0x0200 - 0x03ff) --------------------------------------
|
||||
MBX_IRQ0_HI = 0x0200
|
||||
MBX_IRQ0_LO = 0x0204
|
||||
MBX_RX_STD_PROD_LO = 0x026c
|
||||
MBX_RX_JUMBO_PROD_LO = 0x0274
|
||||
MBX_RX_MINI_PROD_LO = 0x027c
|
||||
MBX_RX_CONS0_LO = 0x0284
|
||||
MBX_TX_HOST_PROD0_LO = 0x0304
|
||||
|
||||
; --- Ethernet MAC (0x0400) --------------------------------------------
|
||||
MAC_MODE = 0x0400
|
||||
MAC_STS = 0x0404
|
||||
MAC_EVT_ENB = 0x0408
|
||||
MAC_LED_CTL = 0x040c
|
||||
MAC_ADDR0_HI = 0x0410
|
||||
MAC_ADDR0_LO = 0x0414
|
||||
MAC_TX_BACKOFF_SEED = 0x0438
|
||||
MAC_RX_MTU = 0x043c
|
||||
MI_COMM = 0x044c
|
||||
MI_STS = 0x0450
|
||||
MI_MODE = 0x0454
|
||||
MAC_TX_MODE = 0x045c
|
||||
MAC_TX_LENGTHS = 0x046c
|
||||
MAC_RX_MODE = 0x0468
|
||||
RX_RULES_CFG = 0x0500
|
||||
|
||||
MAC_MODE_RESET = 0x00000001
|
||||
MAC_MODE_HALF_DUPLEX = 0x00000002
|
||||
MAC_MODE_PORT_MODE_MII = 0x00000004
|
||||
MAC_MODE_PORT_MODE_GMII = 0x00000008
|
||||
MAC_MODE_PORT_MODE_TBI = 0x0000000c
|
||||
MAC_MODE_PORT_MODE_MASK = 0x0000000c
|
||||
MAC_MODE_RX_STATS_EN = 0x00000800
|
||||
MAC_MODE_RX_STATS_CLEAR = 0x00001000
|
||||
MAC_MODE_TX_STATS_EN = 0x00004000
|
||||
MAC_MODE_TX_STATS_CLEAR = 0x00008000
|
||||
MAC_MODE_TXDMA_EN = 0x00200000
|
||||
MAC_MODE_RXDMA_EN = 0x00400000
|
||||
MAC_MODE_FRMHDR_DMA_EN = 0x00800000
|
||||
|
||||
MACSTAT_CFG_CHANGED = 0x00000004
|
||||
MACSTAT_SYNC_CHANGED = 0x00000008
|
||||
MACSTAT_LINK_CHANGED = 0x00001000
|
||||
MACSTAT_MI_COMPLETE = 0x00400000
|
||||
MACSTAT_STICKY = MACSTAT_LINK_CHANGED or MACSTAT_SYNC_CHANGED \
|
||||
or MACSTAT_CFG_CHANGED or MACSTAT_MI_COMPLETE
|
||||
EVTENB_LINK_CHANGED = 0x00001000
|
||||
|
||||
RX_MODE_RESET = 0x00000001
|
||||
RX_MODE_ENABLE = 0x00000002
|
||||
RX_MODE_FLOW_CTRL_ENABLE = 0x00000004
|
||||
RX_MODE_PROMISC = 0x00000100
|
||||
RX_MODE_KEEP_VLAN_TAG = 0x00000400
|
||||
|
||||
TX_MODE_RESET = 0x00000001
|
||||
TX_MODE_ENABLE = 0x00000002
|
||||
TX_MODE_FLOW_CTRL_ENABLE = 0x00000010
|
||||
TXMODE_MBUF_LOCKUP_FIX = 0x00000100
|
||||
|
||||
TX_LENGTHS_DEFAULT = 0x00002620 ; inter packet gap etc.
|
||||
TX_BACKOFF_SEED_MASK = 0x000003ff
|
||||
|
||||
; MI (PHY) access
|
||||
MIMODE_CLK_10MHZ = 0x000c0000 ; "base" value
|
||||
MIMODE_AUTOPOLL = 0x00000010
|
||||
MIMODE_PHYADDR_1 = 0x00000020
|
||||
|
||||
MICOMM_DATA_MASK = 0x0000ffff
|
||||
MICOMM_REG_SHIFT = 16
|
||||
MICOMM_PHY_SHIFT = 21
|
||||
MICOMM_CMD_WRITE = 0x04000000
|
||||
MICOMM_CMD_READ = 0x08000000
|
||||
MICOMM_READFAIL = 0x10000000
|
||||
MICOMM_BUSY = 0x20000000
|
||||
|
||||
MISTS_LINK = 0x00000001
|
||||
MISTS_10MBPS = 0x00000002
|
||||
|
||||
; --- Send Data Initiator (0x0c00) -------------------------------------
|
||||
SDI_MODE = 0x0c00
|
||||
SDI_STATS_ENABLE_MASK = 0x0c08
|
||||
SDI_STATS_CTL = 0x0c0c
|
||||
SDIMODE_ENABLE = 0x00000002
|
||||
|
||||
; --- Send Data Completion (0x1000) ------------------------------------
|
||||
SDC_MODE = 0x1000
|
||||
SDCMODE_ENABLE = 0x00000002
|
||||
|
||||
; --- Send BD Ring Selector (0x1400) -----------------------------------
|
||||
SRS_MODE = 0x1400
|
||||
SRSMODE_ENABLE = 0x00000002
|
||||
|
||||
; --- Send BD Initiator (0x1800) ---------------------------------------
|
||||
SBDI_MODE = 0x1800
|
||||
SBDIMODE_ENABLE = 0x00000002
|
||||
|
||||
; --- Send BD Completion (0x1c00) --------------------------------------
|
||||
SBDC_MODE = 0x1c00
|
||||
SBDCMODE_ENABLE = 0x00000002
|
||||
|
||||
; --- Receive List Placement (0x2000) ----------------------------------
|
||||
RXLP_MODE = 0x2000
|
||||
RXLP_CFG = 0x2010
|
||||
RXLP_STATS_CTL = 0x2014
|
||||
RXLP_STATS_ENABLE_MASK = 0x2018
|
||||
RXLPMODE_ENABLE = 0x00000002
|
||||
RXLP_CFG_DEFAULT = 0x00000181
|
||||
|
||||
; --- Receive Data & BD Initiator (0x2400) -----------------------------
|
||||
RDBDI_MODE = 0x2400
|
||||
RDBDIMODE_ENABLE = 0x00000002
|
||||
RDBDIMODE_ATTN = 0x00000004
|
||||
|
||||
; Receive ring control blocks live in this block
|
||||
RX_JUMBO_RCB_HADDR_HI = 0x2440
|
||||
RX_JUMBO_RCB_HADDR_LO = 0x2444
|
||||
RX_JUMBO_RCB_MAXLEN_FLAGS = 0x2448
|
||||
RX_JUMBO_RCB_NICADDR = 0x244c
|
||||
RX_STD_RCB_HADDR_HI = 0x2450
|
||||
RX_STD_RCB_HADDR_LO = 0x2454
|
||||
RX_STD_RCB_MAXLEN_FLAGS = 0x2458
|
||||
RX_STD_RCB_NICADDR = 0x245c
|
||||
RX_MINI_RCB_HADDR_HI = 0x2460
|
||||
RX_MINI_RCB_HADDR_LO = 0x2464
|
||||
RX_MINI_RCB_MAXLEN_FLAGS = 0x2468
|
||||
RX_MINI_RCB_NICADDR = 0x246c
|
||||
|
||||
; --- Receive Data Completion (0x2800) ---------------------------------
|
||||
RDC_MODE = 0x2800
|
||||
RDCMODE_ENABLE = 0x00000002
|
||||
RDCMODE_ATTN = 0x00000004
|
||||
|
||||
; --- Receive BD Initiator (0x2c00) ------------------------------------
|
||||
RBDI_MODE = 0x2c00
|
||||
RBDI_STD_REPL_THRESH = 0x2c18
|
||||
RBDI_JUMBO_REPL_THRESH = 0x2c1c
|
||||
RBDIMODE_ENABLE = 0x00000002
|
||||
RBDIMODE_ATTN = 0x00000004
|
||||
|
||||
; --- Receive BD Completion (0x3000) -----------------------------------
|
||||
RBDC_MODE = 0x3000
|
||||
RBDCMODE_ENABLE = 0x00000002
|
||||
RBDCMODE_ATTN = 0x00000004
|
||||
|
||||
; --- Receive List Selector (0x3400), pre-5705 only --------------------
|
||||
RXLS_MODE = 0x3400
|
||||
RXLSMODE_ENABLE = 0x00000002
|
||||
|
||||
; --- Host Coalescing (0x3c00) -----------------------------------------
|
||||
HCC_MODE = 0x3c00
|
||||
HCC_STATUS = 0x3c04
|
||||
HCC_RX_COAL_TICKS = 0x3c08
|
||||
HCC_TX_COAL_TICKS = 0x3c0c
|
||||
HCC_RX_MAX_COAL_BDS = 0x3c10
|
||||
HCC_TX_MAX_COAL_BDS = 0x3c14
|
||||
HCC_RX_COAL_TICKS_INT = 0x3c18
|
||||
HCC_TX_COAL_TICKS_INT = 0x3c1c
|
||||
HCC_RX_MAX_COAL_BDS_INT = 0x3c20
|
||||
HCC_TX_MAX_COAL_BDS_INT = 0x3c24
|
||||
HCC_STATS_TICKS = 0x3c28
|
||||
HCC_STATS_ADDR_HI = 0x3c30
|
||||
HCC_STATS_ADDR_LO = 0x3c34
|
||||
HCC_STATUSBLK_ADDR_HI = 0x3c38
|
||||
HCC_STATUSBLK_ADDR_LO = 0x3c3c
|
||||
HCC_STATS_BASEADDR = 0x3c40
|
||||
HCC_STATUSBLK_BASEADDR = 0x3c44
|
||||
|
||||
HCCMODE_RESET = 0x00000001
|
||||
HCCMODE_ENABLE = 0x00000002
|
||||
HCCMODE_ATTN = 0x00000004
|
||||
HCCMODE_COAL_NOW = 0x00000008
|
||||
HCCMODE_STATBLKSZ_32BYTE = 0x00000100
|
||||
|
||||
; --- Memory Arbiter (0x4000) ------------------------------------------
|
||||
MARB_MODE = 0x4000
|
||||
MARBMODE_ENABLE = 0x00000002
|
||||
|
||||
; --- Buffer Manager (0x4400), pre-5705 needs explicit setup -----------
|
||||
BMAN_MODE = 0x4400
|
||||
BMAN_STATUS = 0x4404
|
||||
BMAN_MBUFPOOL_BASEADDR = 0x4408
|
||||
BMAN_MBUFPOOL_LEN = 0x440c
|
||||
BMAN_MBUFPOOL_READDMA_LOWAT = 0x4410
|
||||
BMAN_MBUFPOOL_MACRX_LOWAT = 0x4414
|
||||
BMAN_MBUFPOOL_HIWAT = 0x4418
|
||||
BMAN_DMA_DESCPOOL_BASEADDR = 0x442c
|
||||
BMAN_DMA_DESCPOOL_LEN = 0x4430
|
||||
BMAN_DMA_DESCPOOL_LOWAT = 0x4434
|
||||
BMAN_DMA_DESCPOOL_HIWAT = 0x4438
|
||||
|
||||
BMANMODE_RESET = 0x00000001
|
||||
BMANMODE_ENABLE = 0x00000002
|
||||
BMANMODE_ATTN = 0x00000004
|
||||
BMANMODE_LOMBUF_ATTN = 0x00000010
|
||||
|
||||
BUFFPOOL_1 = 0x00010000 ; NIC SRAM mbuf pool
|
||||
BUFFPOOL_1_LEN = 0x00018000
|
||||
DMA_DESCRIPTORS = 0x00002000
|
||||
DMA_DESCRIPTORS_LEN = 0x00002000
|
||||
|
||||
; --- Read / Write DMA -------------------------------------------------
|
||||
RDMA_MODE = 0x4800
|
||||
RDMA_RSRVCTRL = 0x4900
|
||||
WDMA_MODE = 0x4c00
|
||||
|
||||
RDMAMODE_ENABLE = 0x00000002
|
||||
RDMAMODE_ALL_ATTNS = 0x000003fc
|
||||
RDMAMODE_BD_SBD_CRPT_ATTN = 0x00000800
|
||||
RDMAMODE_MBUF_RBD_CRPT_ATTN = 0x00001000
|
||||
RDMAMODE_MBUF_SBD_CRPT_ATTN = 0x00002000
|
||||
RDMAMODE_FIFO_LONG_BURST = 0x00030000
|
||||
RDMA_RSRVCTRL_FIFO_OFLW_FIX = 0x00000004
|
||||
|
||||
WDMAMODE_ENABLE = 0x00000002
|
||||
WDMAMODE_ALL_ATTNS = 0x000003fc
|
||||
WDMAMODE_STATUS_TAG_FIX = 0x20000000
|
||||
|
||||
; --- Flow Through Queues (0x5c00) -------------------------------------
|
||||
FTQ_RESET = 0x5c00
|
||||
|
||||
; --- Mode / misc control (0x6800) -------------------------------------
|
||||
MODE_CTRL = 0x6800
|
||||
MISC_CFG = 0x6804
|
||||
MISC_LOCAL_CTL = 0x6808
|
||||
EE_ADDR = 0x6838
|
||||
EE_DATA = 0x683c
|
||||
|
||||
MODECTL_BYTESWAP_NONFRAME = 0x00000002
|
||||
MODECTL_WORDSWAP_NONFRAME = 0x00000004
|
||||
MODECTL_BYTESWAP_DATA = 0x00000010
|
||||
MODECTL_WORDSWAP_DATA = 0x00000020
|
||||
MODECTL_NO_TX_INTR = 0x00002000
|
||||
MODECTL_NO_RX_INTR = 0x00004000
|
||||
MODECTL_FORCE_PCI32 = 0x00008000
|
||||
MODECTL_HOST_STACKUP = 0x00010000
|
||||
MODECTL_HOST_SENDBDS = 0x00020000
|
||||
MODECTL_TX_ATTN_INTR = 0x01000000
|
||||
MODECTL_RX_ATTN_INTR = 0x02000000
|
||||
MODECTL_MAC_ATTN_INTR = 0x04000000
|
||||
MODECTL_DMA_ATTN_INTR = 0x08000000
|
||||
MODECTL_FLOW_ATTN_INTR = 0x10000000
|
||||
|
||||
MISCCFG_RESET_CORE_CLOCKS = 0x00000001
|
||||
MISCCFG_TIMER_PRESCALE_66MHZ = (65 shl 1)
|
||||
|
||||
MLC_INTR_ONATTN = 0x00000008
|
||||
MLC_AUTO_EEPROM = 0x01000000
|
||||
|
||||
; Serial EEPROM auto access
|
||||
EEADDR_ADDRESS = 0x0000fffc
|
||||
EEADDR_START = 0x02000000
|
||||
EEADDR_RESET = 0x20000000
|
||||
EEADDR_DONE = 0x40000000
|
||||
EEADDR_RW = 0x80000000 ; 1 = read
|
||||
HALFCLK_384SCL = 0x60
|
||||
EE_READCMD = (HALFCLK_384SCL shl 16) or EEADDR_START or EEADDR_RW or EEADDR_DONE
|
||||
EE_MAC_OFFSET = 0x7c
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; NIC internal memory (reached through PCI_MEMWIN_BASEADDR/DATA)
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
NICMEM_SEND_RING_RCB = 0x0100 ; 16 RCBs, 16 bytes each
|
||||
NICMEM_RX_RETURN_RING_RCB = 0x0200 ; 16 RCBs, 16 bytes each
|
||||
NICMEM_SOFTWARE_MAC = 0x0c14 ; "HK" signature + MAC
|
||||
NICMEM_SEND_RING_1_TO_4 = 0x4000 ; TX ring mirror, pre-5705
|
||||
NICMEM_STD_RX_RINGS = 0x6000 ; RX std ring mirror
|
||||
|
||||
STATS_BLOCK_NIC = 0x00000300
|
||||
STATUS_BLOCK_NIC = 0x00000b00
|
||||
|
||||
; Ring control block layout (both in NIC memory and as CSRs)
|
||||
RCB_HADDR_HI = 0x00
|
||||
RCB_HADDR_LO = 0x04
|
||||
RCB_MAXLEN_FLAGS = 0x08
|
||||
RCB_NICADDR = 0x0c
|
||||
sizeof.rcb = 0x10
|
||||
|
||||
RCB_FLAG_USE_EXT_RX_BD = 0x0001
|
||||
RCB_FLAG_RING_DISABLED = 0x0002
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; Chip identification
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
; The chip id is the top half of PCI_MISC_CTL, and the ASIC revision is
|
||||
; its top nibble-and-a-bit: asic_rev = chip_id shr 12.
|
||||
;
|
||||
; Note that the revision numbering is NOT chronological. The BCM5700,
|
||||
; the oldest part in the family, has revision 0x07, which is larger than
|
||||
; the 0x03 of the 5705. Anything deciding "is this a 5705 or later" by
|
||||
; comparing revisions therefore gets the 5700 wrong - see is_5705_plus
|
||||
; in the driver.
|
||||
|
||||
ASICREV_BCM5701 = 0x00
|
||||
ASICREV_BCM5703 = 0x01
|
||||
ASICREV_BCM5704 = 0x02
|
||||
ASICREV_BCM5705 = 0x03
|
||||
ASICREV_BCM5750 = 0x04
|
||||
ASICREV_BCM5714_A0 = 0x05
|
||||
ASICREV_BCM5752 = 0x06
|
||||
ASICREV_BCM5700 = 0x07
|
||||
ASICREV_BCM5780 = 0x08
|
||||
ASICREV_BCM5714 = 0x09
|
||||
ASICREV_BCM5755 = 0x0a
|
||||
ASICREV_BCM5787 = 0x0b
|
||||
ASICREV_BCM5906 = 0x0c
|
||||
ASICREV_USE_PRODID_REG = 0x0f
|
||||
ASICREV_BCM57780 = 0x57780
|
||||
|
||||
;--- 5700 class, pre-5705 programming model ---------------------------
|
||||
CHIPID_BCM5700_A0 = 0x7000
|
||||
CHIPID_BCM5700_B0 = 0x7100
|
||||
CHIPID_BCM5700_B2 = 0x7102
|
||||
CHIPID_BCM5700_B3 = 0x7103
|
||||
CHIPID_BCM5700_ALTIMA = 0x7104
|
||||
CHIPID_BCM5700_C0 = 0x7200
|
||||
|
||||
CHIPID_BCM5701_A0 = 0x0000
|
||||
CHIPID_BCM5701_B0 = 0x0100
|
||||
CHIPID_BCM5701_B2 = 0x0102
|
||||
CHIPID_BCM5701_B5 = 0x0105
|
||||
|
||||
CHIPID_BCM5703_A0 = 0x1000
|
||||
CHIPID_BCM5703_A1 = 0x1001
|
||||
CHIPID_BCM5703_A2 = 0x1002
|
||||
CHIPID_BCM5703_A3 = 0x1003
|
||||
CHIPID_BCM5703_B0 = 0x1100
|
||||
|
||||
CHIPID_BCM5704_A0 = 0x2000
|
||||
CHIPID_BCM5704_A1 = 0x2001
|
||||
CHIPID_BCM5704_A2 = 0x2002
|
||||
CHIPID_BCM5704_A3 = 0x2003
|
||||
CHIPID_BCM5704_B0 = 0x2100
|
||||
|
||||
;--- 5705 and later ---------------------------------------------------
|
||||
CHIPID_BCM5705_A0 = 0x3000
|
||||
CHIPID_BCM5705_A1 = 0x3001
|
||||
CHIPID_BCM5705_A2 = 0x3002
|
||||
CHIPID_BCM5705_A3 = 0x3003
|
||||
|
||||
CHIPID_BCM5750_A0 = 0x4000
|
||||
CHIPID_BCM5750_A1 = 0x4001
|
||||
CHIPID_BCM5750_B0 = 0x4010
|
||||
CHIPID_BCM5750_B1 = 0x4101
|
||||
CHIPID_BCM5750_C0 = 0x4200
|
||||
CHIPID_BCM5750_C1 = 0x4201
|
||||
CHIPID_BCM5750_C2 = 0x4202
|
||||
|
||||
CHIPID_BCM57780_A0 = 0x57780000
|
||||
CHIPID_BCM57780_A1 = 0x57780001
|
||||
|
||||
; Later members of the family. These are recognised well enough to be
|
||||
; named, but none of them has been tested with this driver and several
|
||||
; want setup it does not do yet (clock power management on the 5784 and
|
||||
; 5761 class, the PHY quirks on the 5906, jumbo support on the 5714 and
|
||||
; 5780). Left here so an unknown card can at least be identified from
|
||||
; the log; uncomment the matching chip_table entries once one has
|
||||
; actually been tried.
|
||||
;
|
||||
; CHIPID_BCM5714_A0 = 0x5000
|
||||
; CHIPID_BCM5752_A0 = 0x6000
|
||||
; CHIPID_BCM5752_A1 = 0x6001
|
||||
; CHIPID_BCM5752_A2 = 0x6002
|
||||
; CHIPID_BCM5714_B0 = 0x8000
|
||||
; CHIPID_BCM5714_B3 = 0x8003
|
||||
; CHIPID_BCM5715_A0 = 0x9000
|
||||
; CHIPID_BCM5715_A1 = 0x9001
|
||||
; CHIPID_BCM5715_A3 = 0x9003
|
||||
; CHIPID_BCM5755_A0 = 0xa000
|
||||
; CHIPID_BCM5755_A1 = 0xa001
|
||||
; CHIPID_BCM5755_A2 = 0xa002
|
||||
; CHIPID_BCM5722_A0 = 0xa200
|
||||
; CHIPID_BCM5787_A0 = 0xb000
|
||||
; CHIPID_BCM5787_A1 = 0xb001
|
||||
; CHIPID_BCM5787_A2 = 0xb002
|
||||
; CHIPID_BCM5906_A1 = 0xc001
|
||||
; CHIPID_BCM5906_A2 = 0xc002
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; DMA structures
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
; Status block. The chip DMA-writes it whenever something happened.
|
||||
; Only the first 32 bytes are used when STATBLKSZ_32BYTE is selected;
|
||||
; the tail is reserved so the hardware never writes past the struct.
|
||||
struct status_block
|
||||
status_word dd ? ; bit0 = UPDATED
|
||||
tag dd ?
|
||||
rx_jumbo_consumer dw ?
|
||||
rx_std_consumer dw ?
|
||||
rx_mini_consumer dw ?
|
||||
reserved0 dw ?
|
||||
rx_prod_idx dw ? ; return ring 0 producer
|
||||
tx_cons_idx dw ? ; send ring 0 consumer
|
||||
rb 12 ; idx[1..3], written in 32 byte mode
|
||||
rb 48 ; idx[4..15], 80 byte mode
|
||||
ends
|
||||
|
||||
STATUSFLAG_UPDATED = 0x00000001
|
||||
STATUSFLAG_LINKSTATE_CHANGED = 0x00000002
|
||||
STATUSFLAG_ERROR = 0x00000004
|
||||
|
||||
struct tx_bd
|
||||
addr_hi dd ?
|
||||
addr_lo dd ?
|
||||
len_flags dd ? ; length in high word, flags in low
|
||||
vlan_tag dd ?
|
||||
ends
|
||||
|
||||
struct rx_bd
|
||||
addr_hi dd ?
|
||||
addr_lo dd ?
|
||||
len dw ? ; frame length, FCS included
|
||||
idx dw ? ; opaque, we store the std ring slot
|
||||
flags dw ?
|
||||
type dw ?
|
||||
tcp_udp_cksum dw ?
|
||||
ip_cksum dw ?
|
||||
vlan_tag dw ?
|
||||
error_flag dw ?
|
||||
reserved dd ?
|
||||
opaque dd ?
|
||||
ends
|
||||
|
||||
TXBDFLAG_TCP_UDP_CKSUM = 0x0001
|
||||
TXBDFLAG_IP_CKSUM = 0x0002
|
||||
TXBDFLAG_END = 0x0004
|
||||
TXBDFLAG_VLAN_TAG = 0x0040
|
||||
TXBDFLAG_COAL_NOW = 0x0080
|
||||
|
||||
RXBDFLAG_END = 0x0004
|
||||
RXBDFLAG_VLAN_TAG = 0x0040
|
||||
RXBDFLAG_ERROR = 0x0400
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; Broadcom PHY
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
PHY_ADDR = 1
|
||||
PHY_BMCR = 0x00
|
||||
PHY_BMSR = 0x01
|
||||
PHY_AUX_STAT = 0x19
|
||||
|
||||
; Basic mode status register. The link and remote fault bits latch low,
|
||||
; so read it twice to get the current state.
|
||||
PHY_BMSR_LINK = 0x0004
|
||||
PHY_BMSR_AUTONEG_ABLE = 0x0008
|
||||
PHY_BMSR_REMOTE_FAULT = 0x0010
|
||||
PHY_BMSR_AUTONEG_COMP = 0x0020
|
||||
|
||||
; Auto-negotiation result, bits 10:8 of the auxiliary status register.
|
||||
; Note that code 4 is 100BASE-T4 - leaving it out shifts everything
|
||||
; above it by one and reports gigabit links as 100 Mbit.
|
||||
AUX_SPEED_MASK = 0x0700
|
||||
AUX_SPEED_10HALF = 0x0100
|
||||
AUX_SPEED_10FULL = 0x0200
|
||||
AUX_SPEED_100HALF = 0x0300
|
||||
AUX_SPEED_100T4 = 0x0400
|
||||
AUX_SPEED_100FULL = 0x0500
|
||||
AUX_SPEED_1000HALF = 0x0600
|
||||
AUX_SPEED_1000FULL = 0x0700
|
||||
@@ -1,437 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; Broadcom NetXtreme 57xx driver for KolibriOS ;;
|
||||
;; ;;
|
||||
;; GNU GENERAL PUBLIC LICENSE ;;
|
||||
;; Version 2, June 1991 ;;
|
||||
;; ;;
|
||||
;; Broadcom's programmers's manual for the BCM57xx ;;
|
||||
;; http://www.broadcom.com/collateral/pg/57XX-PG105-R.pdf ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
format PE DLL native
|
||||
entry START
|
||||
|
||||
CURRENT_API = 0x0200
|
||||
COMPATIBLE_API = 0x0100
|
||||
API_VERSION = (COMPATIBLE_API shl 16) + CURRENT_API
|
||||
|
||||
; configureable area
|
||||
|
||||
MAX_DEVICES = 16
|
||||
|
||||
__DEBUG__ = 1
|
||||
__DEBUG_LEVEL__ = 2
|
||||
|
||||
TX_RING_SIZE = 128 ; Number of packets in send ring buffer
|
||||
RX_RING_SIZE = 128 ; Number of packets in receive ring buffer
|
||||
|
||||
; end configureable area
|
||||
|
||||
section '.flat' readable writable executable
|
||||
|
||||
include '../proc32.inc'
|
||||
include '../struct.inc'
|
||||
include '../macros.inc'
|
||||
include '../fdo.inc'
|
||||
include '../netdrv.inc'
|
||||
|
||||
if (bsr TX_RING_SIZE)>(bsf TX_RING_SIZE)
|
||||
display 'TX_RING_SIZE must be a power of two'
|
||||
err
|
||||
end if
|
||||
|
||||
if (bsr RX_RING_SIZE)>(bsf RX_RING_SIZE)
|
||||
display 'RX_RING_SIZE must be a power of two'
|
||||
err
|
||||
end if
|
||||
|
||||
struct device ETH_DEVICE
|
||||
|
||||
mmio_addr dd ?
|
||||
pci_bus dd ?
|
||||
pci_dev dd ?
|
||||
irq_line db ?
|
||||
|
||||
cur_tx dd ?
|
||||
last_tx dd ?
|
||||
|
||||
rb 0x100 - ($ and 0xff) ; align 256
|
||||
rx_desc rd 256/8
|
||||
|
||||
rb 0x100 - ($ and 0xff) ; align 256
|
||||
tx_desc rd 256/8
|
||||
|
||||
ends
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; proc START ;;
|
||||
;; ;;
|
||||
;; (standard driver proc) ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
proc START c, reason:dword, cmdline:dword
|
||||
|
||||
cmp [reason], DRV_ENTRY
|
||||
jne .fail
|
||||
|
||||
DEBUGF 1,"Loading driver\n"
|
||||
invoke RegService, my_service, service_proc
|
||||
ret
|
||||
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
endp
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; proc SERVICE_PROC ;;
|
||||
;; ;;
|
||||
;; (standard driver proc) ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
proc service_proc stdcall, ioctl:dword
|
||||
|
||||
mov edx, [ioctl]
|
||||
mov eax, [edx + IOCTL.io_code]
|
||||
|
||||
;------------------------------------------------------
|
||||
|
||||
cmp eax, 0 ;SRV_GETVERSION
|
||||
jne @F
|
||||
|
||||
cmp [edx + IOCTL.out_size], 4
|
||||
jb .fail
|
||||
mov eax, [edx + IOCTL.output]
|
||||
mov [eax], dword API_VERSION
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------
|
||||
@@:
|
||||
cmp eax, 1 ;SRV_HOOK
|
||||
jne .fail
|
||||
|
||||
cmp [edx + IOCTL.inp_size], 3 ; Data input must be at least 3 bytes
|
||||
jb .fail
|
||||
|
||||
mov eax, [edx + IOCTL.input]
|
||||
cmp byte [eax], 1 ; 1 means device number and bus number (pci) are given
|
||||
jne .fail ; other types arent supported for this card yet
|
||||
|
||||
; check if the device is already listed
|
||||
|
||||
mov esi, device_list
|
||||
mov ecx, [devices]
|
||||
test ecx, ecx
|
||||
jz .firstdevice
|
||||
|
||||
; mov eax, [edx + IOCTL.input] ; get the pci bus and device numbers
|
||||
mov ax, [eax+1] ;
|
||||
.nextdevice:
|
||||
mov ebx, [esi]
|
||||
cmp al, byte [ebx + device.pci_bus]
|
||||
jne .next
|
||||
cmp ah, byte [ebx + device.pci_dev]
|
||||
je .find_devicenum ; Device is already loaded, let's find it's device number
|
||||
.next:
|
||||
add esi, 4
|
||||
loop .nextdevice
|
||||
|
||||
|
||||
; This device doesnt have its own eth_device structure yet, lets create one
|
||||
.firstdevice:
|
||||
cmp [devices], MAX_DEVICES ; First check if the driver can handle one more card
|
||||
jae .fail
|
||||
|
||||
allocate_and_clear ebx, sizeof.device, .fail ; Allocate the buffer for device structure
|
||||
|
||||
; Fill in the direct call addresses into the struct
|
||||
|
||||
mov [ebx + device.reset], reset
|
||||
mov [ebx + device.transmit], transmit
|
||||
mov [ebx + device.unload], unload
|
||||
mov [ebx + device.name], my_service
|
||||
|
||||
; save the pci bus and device numbers
|
||||
|
||||
mov eax, [edx + IOCTL.input]
|
||||
movzx ecx, byte [eax+1]
|
||||
mov [ebx + device.pci_bus], ecx
|
||||
movzx ecx, byte [eax+2]
|
||||
mov [ebx + device.pci_dev], ecx
|
||||
|
||||
; Now, it's time to find the base mmio addres of the PCI device
|
||||
|
||||
stdcall PCI_find_mmio, [ebx + device.pci_bus], [ebx + device.pci_dev]
|
||||
test eax, eax
|
||||
jz .destroy
|
||||
|
||||
; Create virtual mapping of the physical memory
|
||||
|
||||
invoke MapIoMem, eax, 10000h, PG_SW+PG_NOCACHE
|
||||
mov [ebx + device.mmio_addr], eax
|
||||
|
||||
; We've found the mmio address, find IRQ now
|
||||
|
||||
invoke PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.interrupt_line
|
||||
mov [ebx + device.irq_line], al
|
||||
|
||||
DEBUGF 1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
|
||||
[ebx + device.pci_dev]:1,[ebx + device.pci_bus]:1,[ebx + device.irq_line]:1,[ebx + device.mmio_addr]:8
|
||||
|
||||
; Ok, the eth_device structure is ready, let's probe the device
|
||||
call probe ; this function will output in eax
|
||||
test eax, eax
|
||||
jnz .err ; If an error occured, exit
|
||||
|
||||
mov eax, [devices] ; Add the device structure to our device list
|
||||
mov [device_list+4*eax], ebx ; (IRQ handler uses this list to find device)
|
||||
inc [devices] ;
|
||||
|
||||
mov [ebx + device.type], NET_TYPE_ETH
|
||||
invoke NetRegDev
|
||||
|
||||
cmp eax, -1
|
||||
je .destroy
|
||||
|
||||
ret
|
||||
|
||||
; If the device was already loaded, find the device number and return it in eax
|
||||
|
||||
.find_devicenum:
|
||||
DEBUGF 1,"Trying to find device number of already registered device\n"
|
||||
invoke NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx
|
||||
; into a device number in edi
|
||||
mov eax, edi ; Application wants it in eax instead
|
||||
DEBUGF 1,"Kernel says: %u\n", eax
|
||||
ret
|
||||
|
||||
; If an error occured, remove all allocated data and exit (returning -1 in eax)
|
||||
|
||||
.destroy:
|
||||
; todo: reset device into virgin state
|
||||
|
||||
.err:
|
||||
invoke KernelFree, ebx
|
||||
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
;------------------------------------------------------
|
||||
endp
|
||||
|
||||
|
||||
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
|
||||
;; ;;
|
||||
;; Actual Hardware dependent code starts here ;;
|
||||
;; ;;
|
||||
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
|
||||
|
||||
unload:
|
||||
; TODO: (in this particular order)
|
||||
;
|
||||
; - Stop the device
|
||||
; - Detach int handler
|
||||
; - Remove device from local list (device_list)
|
||||
; - call unregister function in kernel
|
||||
; - Remove all allocated structures and buffers the card used
|
||||
|
||||
or eax, -1
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; probe: enables the device (if it really is BCM57XX)
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
probe:
|
||||
|
||||
DEBUGF 1,"Probe\n"
|
||||
|
||||
; Make the device a bus master
|
||||
invoke PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command
|
||||
or al, PCI_CMD_MASTER + PCI_CMD_MMIO + PCI_CMD_PIO
|
||||
invoke PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax
|
||||
|
||||
; TODO: validate the device
|
||||
|
||||
reset:
|
||||
|
||||
DEBUGF 1,"Reset\n"
|
||||
|
||||
movzx eax, [ebx + device.irq_line]
|
||||
DEBUGF 1,"Attaching int handler to irq %x\n", eax:1
|
||||
invoke AttachIntHandler, eax, int_handler, ebx
|
||||
test eax, eax
|
||||
jnz @f
|
||||
DEBUGF 1,"\nCould not attach int handler!\n"
|
||||
; or eax, -1
|
||||
; ret
|
||||
@@:
|
||||
|
||||
call read_mac
|
||||
|
||||
; Set the mtu, kernel will be able to send now
|
||||
mov [ebx + device.mtu], 1514
|
||||
|
||||
; Set link state to unknown
|
||||
mov [ebx + device.state], ETH_LINK_UNKNOWN
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
align 4
|
||||
read_mac:
|
||||
|
||||
DEBUGF 1,"Read MAC\n"
|
||||
|
||||
mov esi, [ebx + device.mmio_addr]
|
||||
lea edi, [ebx + device.mac]
|
||||
movsd
|
||||
movsw
|
||||
|
||||
.mac_ok:
|
||||
DEBUGF 1,"MAC = %x-%x-%x-%x-%x-%x\n",\
|
||||
[ebx + device.mac+0]:2,[ebx + device.mac+1]:2,[ebx + device.mac+2]:2,[ebx + device.mac+3]:2,[ebx + device.mac+4]:2,[ebx + device.mac+5]:2
|
||||
|
||||
ret
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Transmit ;;
|
||||
;; ;;
|
||||
;; In: pointer to device structure in ebx ;;
|
||||
;; Out: eax = 0 on success ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
align 16
|
||||
proc transmit stdcall bufferptr, buffersize
|
||||
|
||||
spin_lock_irqsave
|
||||
|
||||
DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize]
|
||||
mov eax, [bufferptr]
|
||||
DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
|
||||
[eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
|
||||
[eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
|
||||
[eax+13]:2,[eax+12]:2
|
||||
|
||||
cmp [buffersize], 1514
|
||||
ja .error
|
||||
cmp [buffersize], 60
|
||||
jb .error
|
||||
|
||||
; Program the descriptor
|
||||
|
||||
; test [something], STILL_BUSY?
|
||||
; jnz .overrun
|
||||
|
||||
; TODO: Program the descriptor
|
||||
|
||||
; Update stats
|
||||
inc [ebx + device.packets_tx]
|
||||
mov eax, [buffersize]
|
||||
add dword[ebx + device.bytes_tx], eax
|
||||
adc dword[ebx + device.bytes_tx + 4], 0
|
||||
|
||||
DEBUGF 1,"Transmit OK\n"
|
||||
spin_unlock_irqrestore
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.error:
|
||||
DEBUGF 2, "TX packet error\n"
|
||||
inc [ebx + device.packets_tx_err]
|
||||
invoke NetFree, [bufferptr]
|
||||
|
||||
spin_unlock_irqrestore
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
.overrun:
|
||||
DEBUGF 2, "TX overrun\n"
|
||||
inc [ebx + device.packets_tx_ovr]
|
||||
invoke NetFree, [bufferptr]
|
||||
|
||||
spin_unlock_irqrestore
|
||||
or eax, -1
|
||||
ret
|
||||
|
||||
endp
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Interrupt handler ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;
|
||||
align 16
|
||||
int_handler:
|
||||
|
||||
push ebx esi edi
|
||||
|
||||
mov ebx, [esp+4*4]
|
||||
DEBUGF 1,"INT for 0x%x\n", ebx
|
||||
|
||||
; TODO? if we are paranoid, we can check that the value from ebx is present in the current device_list
|
||||
|
||||
mov edi, [ebx + device.mmio_addr]
|
||||
; mov eax, [edi + REG_ICR]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
|
||||
DEBUGF 1,"Status: %x ", eax
|
||||
|
||||
; TODO: handle interrupts
|
||||
|
||||
pop edi esi ebx
|
||||
xor eax, eax
|
||||
inc eax
|
||||
|
||||
ret
|
||||
|
||||
.nothing:
|
||||
pop edi esi ebx
|
||||
xor eax, eax
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
; End of code
|
||||
|
||||
data fixups
|
||||
end data
|
||||
|
||||
include '../peimport.inc'
|
||||
|
||||
my_service db 'BCM57XX',0 ; max 16 chars include zero
|
||||
|
||||
include_debug_strings ; All data wich FDO uses will be included here
|
||||
|
||||
align 4
|
||||
devices dd 0
|
||||
device_list rd MAX_DEVICES ; This list contains all pointers to device structures the driver is handling
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
ROOT = "../../.."
|
||||
tup.rule("xhci.asm", "fasm %f %o " .. tup.getconfig("PESTRIP_CMD") .. tup.getconfig("KPACK_CMD"), "%B.sys")
|
||||
@@ -0,0 +1,993 @@
|
||||
; Device slots, contexts and pipes for the xHCI driver.
|
||||
; This file is included from xhci.asm.
|
||||
|
||||
; =============================================================================
|
||||
; ============================ Context helpers ================================
|
||||
; =============================================================================
|
||||
|
||||
; Returns the address of one context inside a context structure.
|
||||
; in: eax = base of the structure, ecx = index of the context,
|
||||
; esi -> usb_controller.
|
||||
; out: eax = address of the context.
|
||||
proc xhci_context
|
||||
push ecx edx
|
||||
mov edx, [esi+xhci_controller.ContextSize-XCD]
|
||||
imul edx, ecx
|
||||
add eax, edx
|
||||
pop edx ecx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Zeroes the Input Context. The caller must hold CmdLock.
|
||||
; in: esi -> usb_controller.
|
||||
proc xhci_clear_input_ctx
|
||||
push eax ecx edi
|
||||
mov edi, [esi+xhci_controller.InputCtx-XCD]
|
||||
xor eax, eax
|
||||
mov ecx, 33*64/4
|
||||
rep stosd
|
||||
pop edi ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Returns the pipe of the default control endpoint of the same device, which
|
||||
; represents the device as a whole.
|
||||
; in: ebx -> xhci_pipe. out: eax -> xhci_pipe or 0.
|
||||
proc xhci_ctrl_pipe
|
||||
mov eax, [ebx+xhci_pipe.DevPage]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
mov eax, [eax+XHCI_PIPES_OFS+1*4]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
sub eax, sizeof.xhci_pipe
|
||||
.nothing:
|
||||
ret
|
||||
endp
|
||||
|
||||
; Fills the Slot Context of the Input Context from the device description kept
|
||||
; in a pipe. The caller must hold CmdLock.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe describing the device,
|
||||
; ecx = value for the Context Entries field.
|
||||
proc xhci_fill_slot_ctx
|
||||
push eax ecx edx edi
|
||||
mov eax, [esi+xhci_controller.InputCtx-XCD]
|
||||
push ecx
|
||||
movi ecx, 1
|
||||
call xhci_context
|
||||
pop ecx
|
||||
mov edi, eax
|
||||
; dword 0: Route String, Speed and Context Entries.
|
||||
mov eax, [ebx+xhci_pipe.Route]
|
||||
and eax, 0FFFFFh
|
||||
if XHCI_SUPERSPEED
|
||||
; A SuperSpeed root-port device carries the raw PORTSC speed identifier;
|
||||
; its kernel-visible Speed pretends high-speed and must not get here.
|
||||
mov edx, [ebx+xhci_pipe.PSIV]
|
||||
test edx, edx
|
||||
jnz .havespeed
|
||||
end if
|
||||
mov edx, [ebx+xhci_pipe.Speed]
|
||||
cmp edx, USB_SPEED_FS
|
||||
jz .fs
|
||||
cmp edx, USB_SPEED_LS
|
||||
jz .ls
|
||||
movi edx, XHCI_PSI_HS
|
||||
jmp .havespeed
|
||||
.fs:
|
||||
movi edx, XHCI_PSI_FS
|
||||
jmp .havespeed
|
||||
.ls:
|
||||
movi edx, XHCI_PSI_LS
|
||||
.havespeed:
|
||||
shl edx, 20
|
||||
or eax, edx
|
||||
shl ecx, 27
|
||||
or eax, ecx
|
||||
mov [edi], eax
|
||||
; dword 1: Root Hub Port Number.
|
||||
mov eax, [ebx+xhci_pipe.RootPort]
|
||||
shl eax, 16
|
||||
mov [edi+4], eax
|
||||
; dword 2: the Transaction Translator, if the device is served by one.
|
||||
mov eax, [ebx+xhci_pipe.TTSlot]
|
||||
test eax, eax
|
||||
jz @f
|
||||
mov edx, [ebx+xhci_pipe.TTPort]
|
||||
shl edx, 8
|
||||
or eax, edx
|
||||
@@:
|
||||
mov [edi+8], eax
|
||||
and dword [edi+12], 0
|
||||
pop edi edx ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Fills the Endpoint Context of the Input Context for the given pipe.
|
||||
; The caller must hold CmdLock.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe.
|
||||
proc xhci_fill_ep_ctx
|
||||
push eax ecx edx edi
|
||||
mov eax, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
inc ecx
|
||||
call xhci_context
|
||||
mov edi, eax
|
||||
; dword 0: Interval.
|
||||
mov eax, [ebx+xhci_pipe.Interval]
|
||||
shl eax, 16
|
||||
mov [edi], eax
|
||||
; dword 1: Error Count, Endpoint Type, Max Burst Size and Max Packet Size.
|
||||
mov eax, [ebx+xhci_pipe.EpType]
|
||||
shl eax, 3
|
||||
or eax, 3 shl 1 ; three retries before giving up
|
||||
mov edx, [ebx+xhci_pipe.MaxPacket]
|
||||
mov ecx, edx
|
||||
shr ecx, 11
|
||||
and ecx, 3 ; extra transactions per microframe
|
||||
shl ecx, 8
|
||||
or eax, ecx
|
||||
if XHCI_SUPERSPEED
|
||||
; A SuperSpeed bulk endpoint may allow bursts of several packets; the field
|
||||
; shares its bits with the extra-transactions ones, which are zero then.
|
||||
mov ecx, [ebx+xhci_pipe.MaxBurst]
|
||||
shl ecx, 8
|
||||
or eax, ecx
|
||||
end if
|
||||
and edx, 7FFh
|
||||
shl edx, 16
|
||||
or eax, edx
|
||||
mov [edi+4], eax
|
||||
; dwords 2 and 3: the TR Dequeue Pointer with the Dequeue Cycle State.
|
||||
mov eax, [ebx+xhci_pipe.Enqueue]
|
||||
shl eax, 4
|
||||
add eax, [ebx+xhci_pipe.RingPhys]
|
||||
or eax, [ebx+xhci_pipe.Cycle]
|
||||
mov [edi+8], eax
|
||||
and dword [edi+12], 0
|
||||
; dword 4: Average TRB Length, only a hint for the bandwidth scheduler.
|
||||
mov eax, [ebx+xhci_pipe.MaxPacket]
|
||||
and eax, 7FFh
|
||||
cmp [ebx+xhci_pipe.EpType], XHCI_EP_CONTROL
|
||||
jnz @f
|
||||
movi eax, 8
|
||||
@@:
|
||||
mov [edi+16], eax
|
||||
and dword [edi+20], 0
|
||||
pop edi edx ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; ============================== Slot commands ================================
|
||||
; =============================================================================
|
||||
|
||||
; Issues the Address Device command for a newly created default control pipe.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe. out: eax = 0 on failure.
|
||||
proc xhci_address_device
|
||||
push ebx ecx edx edi
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
mov edx, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov dword [edx+4], 3 ; add the Slot Context and endpoint zero
|
||||
movi ecx, 1
|
||||
call xhci_fill_slot_ctx
|
||||
call xhci_fill_ep_ctx
|
||||
mov [ebx+xhci_pipe.MaxDCI], 1
|
||||
; Point the DCBAA entry of the slot at the Device Context.
|
||||
mov eax, [esi+xhci_controller.CommonPage-XCD]
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
mov edx, [ebx+xhci_pipe.DevPagePhys]
|
||||
mov [eax+ecx*8], edx
|
||||
and dword [eax+ecx*8+4], 0
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_ADDRESS_DEV shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
pop ebx
|
||||
push eax
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
pop eax
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz .ok
|
||||
DEBUGF 1,'K : XHCI: Address Device failed, code %d\n',eax
|
||||
xor eax, eax
|
||||
jmp .nothing
|
||||
.ok:
|
||||
movi eax, 1
|
||||
.nothing:
|
||||
pop edi edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Issues a Configure Endpoint command that adds the given endpoint.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe of the endpoint,
|
||||
; edi -> xhci_pipe of the default control endpoint of the same device.
|
||||
; out: eax = completion code.
|
||||
proc xhci_configure_endpoint
|
||||
push ebx ecx edx esi edi
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
; Drop the endpoint and add it again, so that reopening an endpoint that has
|
||||
; been closed before also works.
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
movi eax, 1
|
||||
shl eax, cl
|
||||
mov edx, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov [edx], eax
|
||||
or eax, 1 ; the Slot Context is always added
|
||||
mov [edx+4], eax
|
||||
call xhci_fill_ep_ctx
|
||||
; The Context Entries field must cover every endpoint in use by the device.
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
cmp ecx, [edi+xhci_pipe.MaxDCI]
|
||||
jae @f
|
||||
mov ecx, [edi+xhci_pipe.MaxDCI]
|
||||
@@:
|
||||
mov [edi+xhci_pipe.MaxDCI], ecx
|
||||
push ebx
|
||||
mov ebx, edi
|
||||
call xhci_fill_slot_ctx
|
||||
pop ebx
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_CONFIG_EP shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
pop ebx
|
||||
push eax
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
pop eax
|
||||
pop edi esi edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Tells the controller where the endpoint has to continue from.
|
||||
; in: esi -> usb_controller, ebx -> xhci_pipe.
|
||||
proc xhci_set_dequeue
|
||||
pushad
|
||||
cmp [ebx+xhci_pipe.SlotId], 0
|
||||
jz .nothing
|
||||
mov eax, [ebx+xhci_pipe.Dequeue]
|
||||
shl eax, 4
|
||||
add eax, [ebx+xhci_pipe.RingPhys]
|
||||
or eax, [ebx+xhci_pipe.Cycle]
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
shl ecx, 16
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, ecx
|
||||
or edx, XHCI_TRB_SET_DEQ shl 10
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_sync
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz .nothing
|
||||
DEBUGF 1,'K : XHCI: Set TR Dequeue Pointer failed, code %d\n',eax
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; =============================== New device ==================================
|
||||
; =============================================================================
|
||||
|
||||
; Called from xhci_port_init and from the hub support code when a new device
|
||||
; has been connected and reset. Enables a device slot for it and hands it over
|
||||
; to the protocol layer.
|
||||
; in: esi -> usb_controller, eax = speed. out: eax = 0 on failure.
|
||||
proc xhci_new_device
|
||||
push ebx ecx edx edi
|
||||
mov [esi+usb_controller.ResettingSpeed], al
|
||||
; 1. Reserve room for the pseudo-pipe that describes the new device. Only the
|
||||
; fields read by xhci_init_pipe are filled in; the layout matches a real pipe,
|
||||
; so the result can be passed to usb_new_device as a usb_pipe pointer.
|
||||
sub esp, sizeof.xhci_pipe + 4
|
||||
mov ebx, esp
|
||||
push ebx
|
||||
mov edi, ebx
|
||||
xor eax, eax
|
||||
mov ecx, (sizeof.xhci_pipe + 4)/4
|
||||
rep stosd
|
||||
pop ebx
|
||||
mov [ebx+sizeof.xhci_pipe], esi ; usb_pipe.Controller
|
||||
movzx eax, [esi+usb_controller.ResettingSpeed]
|
||||
mov [ebx+xhci_pipe.Speed], eax
|
||||
; 2. Compute the root hub port, the route string and the tier of the device.
|
||||
movzx edx, [esi+usb_controller.ResettingPort]
|
||||
mov edi, [esi+usb_controller.ResettingHub]
|
||||
test edi, edi
|
||||
jnz .behind_hub
|
||||
mov eax, [esi+xhci_controller.PortMap-XCD+edx*4]
|
||||
mov [ebx+xhci_pipe.RootPort], eax
|
||||
if XHCI_SUPERSPEED
|
||||
mov eax, [esi+xhci_controller.ResettingPSIV-XCD]
|
||||
mov [ebx+xhci_pipe.PSIV], eax
|
||||
end if
|
||||
jmp .have_topology
|
||||
.behind_hub:
|
||||
; The parent hub is a device too, and its own pipe carries the topology data.
|
||||
mov eax, [edi+USB_HUB_CONFIGPIPE]
|
||||
sub eax, sizeof.xhci_pipe
|
||||
mov ecx, [eax+xhci_pipe.RootPort]
|
||||
mov [ebx+xhci_pipe.RootPort], ecx
|
||||
mov ecx, [eax+xhci_pipe.Depth]
|
||||
mov eax, [eax+xhci_pipe.Route]
|
||||
; The route string holds one nibble per tier, at most five of them.
|
||||
cmp ecx, 5
|
||||
jae .have_route
|
||||
push ecx edx
|
||||
shl ecx, 2
|
||||
inc edx ; the route uses 1-based port numbers
|
||||
cmp edx, 15
|
||||
jbe @f
|
||||
movi edx, 15
|
||||
@@:
|
||||
shl edx, cl
|
||||
or eax, edx
|
||||
pop edx ecx
|
||||
.have_route:
|
||||
inc ecx
|
||||
mov [ebx+xhci_pipe.Depth], ecx
|
||||
mov [ebx+xhci_pipe.Route], eax
|
||||
; 3. Low- and full-speed devices behind a high-speed hub need the address of
|
||||
; the Transaction Translator that serves them.
|
||||
cmp [ebx+xhci_pipe.Speed], USB_SPEED_HS
|
||||
jz .have_topology
|
||||
push ebx
|
||||
mov ecx, edx
|
||||
mov edx, edi
|
||||
invoke usbhc_api.usb_get_tt
|
||||
pop ebx
|
||||
test edx, edx
|
||||
jz .have_topology
|
||||
sub edx, sizeof.xhci_pipe
|
||||
mov eax, [edx+xhci_pipe.SlotId]
|
||||
mov [ebx+xhci_pipe.TTSlot], eax
|
||||
inc ecx
|
||||
mov [ebx+xhci_pipe.TTPort], ecx
|
||||
.have_topology:
|
||||
; 4. Ask the controller for a device slot.
|
||||
xor eax, eax
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
mov edx, XHCI_TRB_ENABLE_SLOT shl 10
|
||||
call xhci_cmd_sync
|
||||
pop ebx
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jnz .fail
|
||||
test edx, edx
|
||||
jz .fail
|
||||
mov [ebx+xhci_pipe.SlotId], edx
|
||||
DEBUGF 1,'K : XHCI new device: slot %d, root port %d, route %x, speed %d\n',edx,[ebx+xhci_pipe.RootPort],[ebx+xhci_pipe.Route],[ebx+xhci_pipe.Speed]
|
||||
; 5. Hand the device over to the protocol layer. It opens the pipe of the
|
||||
; default control endpoint, and that is where the slot is really addressed.
|
||||
lea ecx, [ebx+sizeof.xhci_pipe]
|
||||
invoke usbhc_api.usb_new_device
|
||||
test eax, eax
|
||||
jnz .done
|
||||
; 6. The protocol layer has failed; release the slot again.
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_DISABLE_SLOT shl 10
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_sync
|
||||
xor eax, eax
|
||||
jmp .done
|
||||
.fail:
|
||||
dbgstr 'XHCI: Enable Slot failed'
|
||||
xor eax, eax
|
||||
.done:
|
||||
add esp, sizeof.xhci_pipe + 4
|
||||
pop edi edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; ================================= Pipes =====================================
|
||||
; =============================================================================
|
||||
|
||||
proc xhci_alloc_pipe
|
||||
push ebx ecx edi
|
||||
mov ebx, xhci_ep_mutex
|
||||
invoke usbhc_api.usb_allocate_common, sizeof.xhci_pipe + sizeof.usb_pipe
|
||||
test eax, eax
|
||||
jz @f
|
||||
; Zero the whole block: the kernel may call FreePipe for a pipe whose InitPipe
|
||||
; has never run, and that path must not act on garbage.
|
||||
mov edi, eax
|
||||
push eax
|
||||
xor eax, eax
|
||||
movi ecx, (sizeof.xhci_pipe + sizeof.usb_pipe + 3)/4
|
||||
rep stosd
|
||||
pop eax
|
||||
add eax, sizeof.xhci_pipe
|
||||
@@:
|
||||
pop edi ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
proc xhci_free_pipe stdcall, ptr:dword
|
||||
push ebx esi edi
|
||||
mov ebx, [ptr]
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
mov esi, [ebx+sizeof.xhci_pipe+usb_pipe.Controller]
|
||||
test esi, esi
|
||||
jz .free
|
||||
cmp [ebx+xhci_pipe.SlotId], 0
|
||||
jz .drop_pipe
|
||||
cmp [ebx+xhci_pipe.DCI], 1
|
||||
jnz .drop_pipe
|
||||
; This is the default control endpoint, that is, the handle of the whole
|
||||
; device: release the slot together with the per-device page.
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
mov edx, ecx
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_DISABLE_SLOT shl 10
|
||||
xor eax, eax
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_sync
|
||||
pop ebx
|
||||
; The controller may access the Device Context until the command above
|
||||
; completes, so only now may the DCBAA entry and the slot table forget it.
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
mov edi, [esi+xhci_controller.CommonPage-XCD]
|
||||
and dword [edi+ecx*8], 0
|
||||
and dword [edi+ecx*8+4], 0
|
||||
and [esi+xhci_controller.SlotPages-XCD+ecx*4], 0
|
||||
mov eax, [ebx+xhci_pipe.DevPage]
|
||||
test eax, eax
|
||||
jz .drop_ring
|
||||
invoke KernelFree, eax
|
||||
and [ebx+xhci_pipe.DevPage], 0
|
||||
jmp .drop_ring
|
||||
.drop_pipe:
|
||||
; Remove the pipe from the per-device table, if it is still listed there.
|
||||
; On disconnect the kernel releases the pipes of a device in arbitrary order,
|
||||
; and the pipe of the default control endpoint - the owner of the per-device
|
||||
; page - may well be freed before this one, taking the page with it. The
|
||||
; authoritative pointer is the one in SlotPages: it is cleared when the slot
|
||||
; is released, so it can never point to freed memory.
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
test ecx, ecx
|
||||
jz .drop_ring
|
||||
mov eax, [esi+xhci_controller.SlotPages-XCD+ecx*4]
|
||||
test eax, eax
|
||||
jz .drop_ring
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
cmp ecx, 32
|
||||
jae .drop_ring
|
||||
and dword [eax+XHCI_PIPES_OFS+ecx*4], 0
|
||||
.drop_ring:
|
||||
mov eax, [ebx+xhci_pipe.Ring]
|
||||
test eax, eax
|
||||
jz @f
|
||||
invoke KernelFree, eax
|
||||
and [ebx+xhci_pipe.Ring], 0
|
||||
@@:
|
||||
mov eax, [ebx+xhci_pipe.RingMap]
|
||||
test eax, eax
|
||||
jz .free
|
||||
invoke KernelFree, eax
|
||||
and [ebx+xhci_pipe.RingMap], 0
|
||||
.free:
|
||||
pop edi esi ebx
|
||||
mov eax, [ptr]
|
||||
sub eax, sizeof.xhci_pipe
|
||||
invoke usbhc_api.usb_free_common, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Allocates the transfer ring of a pipe.
|
||||
; in: ebx -> xhci_pipe. out: eax = 0 on failure.
|
||||
proc xhci_alloc_ring
|
||||
push ecx edx
|
||||
call xhci_alloc_page
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
mov [ebx+xhci_pipe.RingMap], eax
|
||||
call xhci_alloc_page
|
||||
test eax, eax
|
||||
jnz @f
|
||||
invoke KernelFree, [ebx+xhci_pipe.RingMap]
|
||||
and [ebx+xhci_pipe.RingMap], 0
|
||||
xor eax, eax
|
||||
jmp .nothing
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.Ring], eax
|
||||
mov [ebx+xhci_pipe.RingPhys], edx
|
||||
; The last entry returns to the beginning of the ring and toggles the cycle.
|
||||
lea ecx, [eax+(XHCI_RING_TRBS-1)*16]
|
||||
mov [ecx], edx
|
||||
mov dword [ecx+12], (XHCI_TRB_LINK shl 10) + XHCI_TRB_TC
|
||||
and [ebx+xhci_pipe.Enqueue], 0
|
||||
and [ebx+xhci_pipe.Dequeue], 0
|
||||
and [ebx+xhci_pipe.Reserved], 0
|
||||
and [ebx+xhci_pipe.FirstFix], 0
|
||||
mov [ebx+xhci_pipe.Cycle], XHCI_TRB_C
|
||||
movi eax, 1
|
||||
.nothing:
|
||||
pop edx ecx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Stores the pipe in the per-device table used by the event ring handler.
|
||||
; in: ebx -> xhci_pipe.
|
||||
proc xhci_register_pipe
|
||||
push eax ecx edx
|
||||
mov eax, [ebx+xhci_pipe.DevPage]
|
||||
test eax, eax
|
||||
jz @f
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
cmp ecx, 32
|
||||
jae @f
|
||||
lea edx, [ebx+sizeof.xhci_pipe]
|
||||
mov [eax+XHCI_PIPES_OFS+ecx*4], edx
|
||||
@@:
|
||||
pop edx ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Computes the Interval field of the Endpoint Context of an interrupt endpoint.
|
||||
; The kernel passes bInterval from the endpoint descriptor: for high-speed
|
||||
; devices it is an exponent of 125 us periods, for low- and full-speed devices
|
||||
; it is a number of frames.
|
||||
; in: ebx -> xhci_pipe, eax = bInterval.
|
||||
proc xhci_calc_interval
|
||||
push eax ecx
|
||||
cmp [ebx+xhci_pipe.Speed], USB_SPEED_HS
|
||||
jnz .low_speed
|
||||
test eax, eax
|
||||
jz @f
|
||||
dec eax
|
||||
@@:
|
||||
jmp .clamp
|
||||
.low_speed:
|
||||
; One frame equals eight periods of 125 us, hence the offset of three.
|
||||
test eax, eax
|
||||
jnz @f
|
||||
movi eax, 1
|
||||
@@:
|
||||
bsr ecx, eax
|
||||
lea eax, [ecx+3]
|
||||
.clamp:
|
||||
cmp eax, 15
|
||||
jbe @f
|
||||
movi eax, 15
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.Interval], eax
|
||||
pop ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Called from usb_open_pipe.
|
||||
; in: edi -> usb_pipe for the target, ecx -> usb_pipe of the config pipe,
|
||||
; esi -> usb_controller, eax -> usb_gtd of the first descriptor,
|
||||
; [ebp+12] = endpoint, [ebp+16] = maxpacket, [ebp+20] = type,
|
||||
; [ebp+24] = interval.
|
||||
; out: eax = 0 on failure.
|
||||
proc xhci_init_pipe
|
||||
virtual at ebp+8
|
||||
.config_pipe dd ?
|
||||
.endpoint dd ?
|
||||
.maxpacket dd ?
|
||||
.type dd ?
|
||||
.interval dd ?
|
||||
end virtual
|
||||
push ebx
|
||||
sub edi, sizeof.xhci_pipe
|
||||
sub ecx, sizeof.xhci_pipe
|
||||
mov ebx, edi ; ebx -> xhci_pipe being initialized
|
||||
; 1. Copy the description of the device from the config pipe.
|
||||
mov eax, [ecx+xhci_pipe.SlotId]
|
||||
mov [ebx+xhci_pipe.SlotId], eax
|
||||
mov eax, [ecx+xhci_pipe.DevPage]
|
||||
mov [ebx+xhci_pipe.DevPage], eax
|
||||
mov eax, [ecx+xhci_pipe.DevPagePhys]
|
||||
mov [ebx+xhci_pipe.DevPagePhys], eax
|
||||
mov eax, [ecx+xhci_pipe.Speed]
|
||||
mov [ebx+xhci_pipe.Speed], eax
|
||||
mov eax, [ecx+xhci_pipe.RootPort]
|
||||
mov [ebx+xhci_pipe.RootPort], eax
|
||||
mov eax, [ecx+xhci_pipe.Route]
|
||||
mov [ebx+xhci_pipe.Route], eax
|
||||
mov eax, [ecx+xhci_pipe.Depth]
|
||||
mov [ebx+xhci_pipe.Depth], eax
|
||||
mov eax, [ecx+xhci_pipe.TTSlot]
|
||||
mov [ebx+xhci_pipe.TTSlot], eax
|
||||
mov eax, [ecx+xhci_pipe.TTPort]
|
||||
mov [ebx+xhci_pipe.TTPort], eax
|
||||
if XHCI_SUPERSPEED
|
||||
mov eax, [ecx+xhci_pipe.PSIV]
|
||||
mov [ebx+xhci_pipe.PSIV], eax
|
||||
end if
|
||||
; 2. Work out the Device Context Index and the endpoint type.
|
||||
mov eax, [.endpoint]
|
||||
test eax, eax
|
||||
jz .control_ep
|
||||
mov ecx, eax
|
||||
and ecx, 15
|
||||
add ecx, ecx
|
||||
test al, 80h
|
||||
jz @f
|
||||
inc ecx
|
||||
or [ebx+xhci_pipe.Flags], XHCI_PIPE_IN
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.DCI], ecx
|
||||
mov eax, [.type]
|
||||
cmp eax, BULK_PIPE
|
||||
jz .bulk
|
||||
cmp eax, INTERRUPT_PIPE
|
||||
jz .interrupt
|
||||
; A control endpoint other than endpoint zero is unusual but legal.
|
||||
mov [ebx+xhci_pipe.EpType], XHCI_EP_CONTROL
|
||||
jmp .have_type
|
||||
.bulk:
|
||||
movi eax, XHCI_EP_BULK_OUT
|
||||
test [ebx+xhci_pipe.Flags], XHCI_PIPE_IN
|
||||
jz @f
|
||||
movi eax, XHCI_EP_BULK_IN
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.EpType], eax
|
||||
jmp .have_type
|
||||
.interrupt:
|
||||
movi eax, XHCI_EP_INT_OUT
|
||||
test [ebx+xhci_pipe.Flags], XHCI_PIPE_IN
|
||||
jz @f
|
||||
movi eax, XHCI_EP_INT_IN
|
||||
@@:
|
||||
mov [ebx+xhci_pipe.EpType], eax
|
||||
mov eax, [.interval]
|
||||
call xhci_calc_interval
|
||||
.have_type:
|
||||
mov eax, [.maxpacket]
|
||||
mov [ebx+xhci_pipe.MaxPacket], eax
|
||||
if XHCI_SUPERSPEED
|
||||
call xhci_ss_get_burst
|
||||
end if
|
||||
jmp .alloc_ring
|
||||
.control_ep:
|
||||
; The default control endpoint always has index one. Until the real packet size
|
||||
; is known from the device descriptor, use the value the specification requires
|
||||
; for the speed of the device: the kernel asks for 64 regardless of the speed,
|
||||
; which is wrong for low- and full-speed devices.
|
||||
mov [ebx+xhci_pipe.DCI], 1
|
||||
mov [ebx+xhci_pipe.EpType], XHCI_EP_CONTROL
|
||||
movi eax, 64
|
||||
cmp [ebx+xhci_pipe.Speed], USB_SPEED_HS
|
||||
jz @f
|
||||
movi eax, 8
|
||||
@@:
|
||||
if XHCI_SUPERSPEED
|
||||
; A SuperSpeed device always uses 512 bytes on the default control endpoint.
|
||||
cmp [ebx+xhci_pipe.PSIV], XHCI_PSI_SS
|
||||
jb @f
|
||||
mov eax, 512
|
||||
@@:
|
||||
end if
|
||||
mov [ebx+xhci_pipe.MaxPacket], eax
|
||||
.alloc_ring:
|
||||
; 3. Allocate the transfer ring.
|
||||
call xhci_alloc_ring
|
||||
test eax, eax
|
||||
jz .fail
|
||||
; 4. Choose the software list the pipe belongs to and insert it there. The
|
||||
; hardware knows nothing about these lists; they exist only so that the kernel
|
||||
; can walk all pipes and reinsert an aborted one.
|
||||
lea edx, [esi+xhci_controller.ControlED-XCD]
|
||||
cmp [.type], BULK_PIPE
|
||||
jb @f
|
||||
lea edx, [esi+xhci_controller.BulkED-XCD]
|
||||
jz @f
|
||||
lea edx, [esi+xhci_controller.IntED-XCD]
|
||||
@@:
|
||||
lea edi, [ebx+sizeof.xhci_pipe]
|
||||
mov [edi+usb_pipe.BaseList], edx
|
||||
mov ecx, [edx+usb_pipe.NextVirt]
|
||||
mov [edi+usb_pipe.NextVirt], ecx
|
||||
mov [edi+usb_pipe.PrevVirt], edx
|
||||
mov [ecx+usb_pipe.PrevVirt], edi
|
||||
mov [edx+usb_pipe.NextVirt], edi
|
||||
; 5. Now do the hardware part.
|
||||
cmp [.endpoint], 0
|
||||
jz .address_device
|
||||
call xhci_register_pipe
|
||||
mov edi, [.config_pipe]
|
||||
sub edi, sizeof.xhci_pipe
|
||||
call xhci_configure_endpoint
|
||||
xhci_trace 'K : XHCI open pipe: slot %d dci %d\n', [ebx+xhci_pipe.SlotId], [ebx+xhci_pipe.DCI]
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz .success
|
||||
DEBUGF 1,'K : XHCI: Configure Endpoint failed, code %d\n',eax
|
||||
jmp .unlink_fail
|
||||
.address_device:
|
||||
; 6. This is a new device: allocate its Device Context, publish the slot and
|
||||
; let the controller give the device a bus address.
|
||||
call xhci_alloc_page
|
||||
test eax, eax
|
||||
jz .unlink_fail
|
||||
mov [ebx+xhci_pipe.DevPage], eax
|
||||
mov [ebx+xhci_pipe.DevPagePhys], edx
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
mov [esi+xhci_controller.SlotPages-XCD+ecx*4], eax
|
||||
call xhci_register_pipe
|
||||
call xhci_address_device
|
||||
test eax, eax
|
||||
jz .free_devpage
|
||||
.success:
|
||||
; usb_open_pipe keeps the pointer to the new pipe in edi across this call, so
|
||||
; it has to be handed back untouched; the branch above has overwritten it with
|
||||
; the pipe of the default control endpoint.
|
||||
lea edi, [ebx+sizeof.xhci_pipe]
|
||||
pop ebx
|
||||
movi eax, 1
|
||||
ret
|
||||
.free_devpage:
|
||||
mov ecx, [ebx+xhci_pipe.SlotId]
|
||||
and [esi+xhci_controller.SlotPages-XCD+ecx*4], 0
|
||||
mov eax, [ebx+xhci_pipe.DevPage]
|
||||
invoke KernelFree, eax
|
||||
and [ebx+xhci_pipe.DevPage], 0
|
||||
.unlink_fail:
|
||||
; Undo the insertion into the software list before failing.
|
||||
lea edi, [ebx+sizeof.xhci_pipe]
|
||||
mov eax, [edi+usb_pipe.NextVirt]
|
||||
mov edx, [edi+usb_pipe.PrevVirt]
|
||||
mov [eax+usb_pipe.PrevVirt], edx
|
||||
mov [edx+usb_pipe.NextVirt], eax
|
||||
.fail:
|
||||
lea edi, [ebx+sizeof.xhci_pipe]
|
||||
pop ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Removes the pipe from the hardware configuration of the device.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe.
|
||||
proc xhci_unlink_pipe
|
||||
pushad
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
cmp [ebx+xhci_pipe.SlotId], 0
|
||||
jz .nothing
|
||||
cmp [ebx+xhci_pipe.DCI], 1
|
||||
jz .nothing ; the slot itself is released by FreePipe
|
||||
call xhci_ctrl_pipe
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
mov edi, eax ; edi -> pipe of endpoint zero
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
movi eax, 1
|
||||
shl eax, cl
|
||||
mov edx, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov [edx], eax ; drop this endpoint
|
||||
mov dword [edx+4], 1 ; keep the Slot Context
|
||||
mov ecx, [edi+xhci_pipe.MaxDCI]
|
||||
test ecx, ecx
|
||||
jnz @f
|
||||
movi ecx, 1
|
||||
@@:
|
||||
push ebx
|
||||
mov ebx, edi
|
||||
call xhci_fill_slot_ctx
|
||||
pop ebx
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_CONFIG_EP shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
; Temporarily removes the pipe from the hardware schedule.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe.
|
||||
proc xhci_disable_pipe
|
||||
pushad
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
cmp [ebx+xhci_pipe.SlotId], 0
|
||||
jz .nothing
|
||||
mov ecx, [ebx+xhci_pipe.DCI]
|
||||
shl ecx, 16
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, ecx
|
||||
or edx, XHCI_TRB_STOP_EP shl 10
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_sync
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
; Reinserts the pipe into the hardware schedule after xhci_disable_pipe, with
|
||||
; an empty transfer queue.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe,
|
||||
; edx -> current descriptor, eax -> new last descriptor.
|
||||
proc xhci_enable_pipe
|
||||
pushad
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
mov eax, [ebx+xhci_pipe.Ring]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
; The queue is empty now, so the ring can be restarted from its beginning.
|
||||
mov edi, eax
|
||||
xor eax, eax
|
||||
mov ecx, 0x1000/4
|
||||
rep stosd
|
||||
mov edi, [ebx+xhci_pipe.RingMap]
|
||||
mov ecx, 0x1000/4
|
||||
rep stosd
|
||||
mov edi, [ebx+xhci_pipe.Ring]
|
||||
add edi, (XHCI_RING_TRBS-1)*16
|
||||
mov eax, [ebx+xhci_pipe.RingPhys]
|
||||
mov [edi], eax
|
||||
mov dword [edi+12], (XHCI_TRB_LINK shl 10) + XHCI_TRB_TC
|
||||
and [ebx+xhci_pipe.Enqueue], 0
|
||||
and [ebx+xhci_pipe.Dequeue], 0
|
||||
and [ebx+xhci_pipe.Reserved], 0
|
||||
and [ebx+xhci_pipe.FirstFix], 0
|
||||
mov [ebx+xhci_pipe.Cycle], XHCI_TRB_C
|
||||
call xhci_set_dequeue
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; ========================== Address and packet size ==========================
|
||||
; =============================================================================
|
||||
|
||||
; Called from usb_set_address_callback. The bus address is chosen by the
|
||||
; controller itself while executing the Address Device command, so the only
|
||||
; thing left to do is to remember the number the kernel has reserved: it asks
|
||||
; for it back on disconnect in order to mark it free again.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe, cl = address.
|
||||
proc xhci_set_device_address
|
||||
movzx eax, cl
|
||||
mov [ebx+xhci_pipe.Address-sizeof.xhci_pipe], eax
|
||||
jmp [usbhc_api.usb_subscribe_control]
|
||||
endp
|
||||
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe. out: eax = address.
|
||||
proc xhci_get_device_address
|
||||
mov eax, [ebx+xhci_pipe.Address-sizeof.xhci_pipe]
|
||||
ret
|
||||
endp
|
||||
|
||||
; Called from usb_get_descr8_callback once the real packet size of the default
|
||||
; control endpoint is known. On xHCI that value lives in the Endpoint Context,
|
||||
; so an Evaluate Context command is needed to update it.
|
||||
; in: esi -> usb_controller, ebx -> usb_pipe, ecx = packet size.
|
||||
proc xhci_set_endpoint_packet_size
|
||||
push ebx ecx edx edi
|
||||
sub ebx, sizeof.xhci_pipe
|
||||
if XHCI_SUPERSPEED
|
||||
; For a SuperSpeed device bMaxPacketSize0 is an exponent, and the only value
|
||||
; the specification allows is 9: use 512 directly instead of the raw byte.
|
||||
cmp [ebx+xhci_pipe.PSIV], XHCI_PSI_SS
|
||||
jb @f
|
||||
mov ecx, 512
|
||||
@@:
|
||||
end if
|
||||
mov [ebx+xhci_pipe.MaxPacket], ecx
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
mov edx, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov dword [edx+4], 2 ; evaluate the default control endpoint
|
||||
call xhci_fill_ep_ctx
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_EVAL_CTX shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
push ebx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
pop ebx
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz @f
|
||||
DEBUGF 1,'K : XHCI: Evaluate Context failed, code %d\n',eax
|
||||
@@:
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
pop edi edx ecx ebx
|
||||
jmp [usbhc_api.usb_subscribe_control]
|
||||
endp
|
||||
|
||||
; If the descriptor that has just completed is the answer to a request for the
|
||||
; hub descriptor, tell the controller that the device is a hub: it has to know
|
||||
; that in order to serve the devices behind it.
|
||||
; in: ebx -> usb_gtd.
|
||||
proc xhci_check_hub_descriptor
|
||||
pushad
|
||||
cmp [ebx+usb_gtd.Callback], 0
|
||||
jz .nothing
|
||||
mov eax, [ebx+usb_gtd.Pipe]
|
||||
mov esi, [eax+usb_pipe.Controller]
|
||||
sub eax, sizeof.xhci_pipe
|
||||
test [eax+xhci_pipe.Flags], XHCI_PIPE_HUBPEND
|
||||
jz .nothing
|
||||
and [eax+xhci_pipe.Flags], not XHCI_PIPE_HUBPEND
|
||||
cmp [ebx+xhci_gtd.Status-sizeof.xhci_gtd], XHCI_CC_SUCCESS
|
||||
jnz .nothing
|
||||
mov edx, [eax+xhci_pipe.HubBuf]
|
||||
test edx, edx
|
||||
jz .nothing
|
||||
cmp byte [edx+1], 29h ; bDescriptorType
|
||||
jnz .nothing
|
||||
or [eax+xhci_pipe.Flags], XHCI_PIPE_ISHUB
|
||||
mov ebx, eax ; ebx -> xhci_pipe of the hub
|
||||
movzx edi, byte [edx+2] ; bNbrPorts
|
||||
movzx ebp, byte [edx+3] ; low byte of wHubCharacteristics
|
||||
shr ebp, 5
|
||||
and ebp, 3 ; Transaction Translator Think Time
|
||||
DEBUGF 1,'K : XHCI: device on slot %d is a hub with %d ports\n',[ebx+xhci_pipe.SlotId],edi
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexLock
|
||||
call xhci_clear_input_ctx
|
||||
mov eax, [esi+xhci_controller.InputCtx-XCD]
|
||||
mov dword [eax+4], 1 ; only the Slot Context is evaluated
|
||||
mov ecx, [ebx+xhci_pipe.MaxDCI]
|
||||
test ecx, ecx
|
||||
jnz @f
|
||||
movi ecx, 1
|
||||
@@:
|
||||
call xhci_fill_slot_ctx
|
||||
; Patch the Slot Context with the fields that describe a hub. Only Configure
|
||||
; Endpoint takes them into account, Evaluate Context would ignore them.
|
||||
mov eax, [esi+xhci_controller.InputCtx-XCD]
|
||||
movi ecx, 1
|
||||
call xhci_context
|
||||
or dword [eax], 1 shl 26 ; this device is a hub
|
||||
cmp [ebx+xhci_pipe.Speed], USB_SPEED_HS
|
||||
jnz @f
|
||||
shl ebp, 16
|
||||
or [eax+8], ebp
|
||||
@@:
|
||||
shl edi, 24
|
||||
or [eax+4], edi ; Number of Ports
|
||||
mov edx, [ebx+xhci_pipe.SlotId]
|
||||
shl edx, 24
|
||||
or edx, XHCI_TRB_CONFIG_EP shl 10
|
||||
mov eax, [esi+xhci_controller.InputCtxPhys-XCD]
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
call xhci_cmd_submit
|
||||
cmp eax, XHCI_CC_SUCCESS
|
||||
jz @f
|
||||
DEBUGF 1,'K : XHCI: cannot mark the device as a hub, code %d\n',eax
|
||||
@@:
|
||||
lea ecx, [esi+xhci_controller.CmdLock-XCD]
|
||||
invoke MutexUnlock
|
||||
.nothing:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
@@ -0,0 +1,135 @@
|
||||
; SuperSpeed support for the xHCI driver, included from xhci.asm when
|
||||
; XHCI_SUPERSPEED is enabled. The pieces too small to live here - the port
|
||||
; map, the Slot Context speed, the 512-byte default control endpoint, the
|
||||
; Max Burst field of the Endpoint Context - sit in the other files under
|
||||
; "if XHCI_SUPERSPEED" guards; this file keeps the self-contained procedures.
|
||||
;
|
||||
; The kernel USB stack knows nothing about SuperSpeed, so it never learns
|
||||
; about it: a SuperSpeed device is announced as a high-speed one, which also
|
||||
; keeps the Transaction Translator logic away from it. The raw PORTSC speed
|
||||
; identifier travels in xhci_pipe.PSIV instead and reaches everything that
|
||||
; really needs it. SuperSpeed hubs are not supported: the kernel only speaks
|
||||
; the USB2 hub protocol, so a device behind a USB3 hub is served by the USB2
|
||||
; half of that hub at high speed.
|
||||
|
||||
; =============================================================================
|
||||
; ============================ SuperSpeed ports ===============================
|
||||
; =============================================================================
|
||||
|
||||
; Called from xhci_new_port for a SuperSpeed root port instead of the USB2
|
||||
; reset entry point: a SuperSpeed link trains itself and the port enables
|
||||
; itself on connect, reporting the speed with no reset at all. When the link
|
||||
; is already up, skip straight to the reset recovery stage, after which
|
||||
; xhci_port_init picks the device up; otherwise try a warm reset.
|
||||
; in: esi -> usb_controller, ecx = port index.
|
||||
proc xhci_ss_start_port
|
||||
push eax edx
|
||||
and [esi+usb_controller.ResettingHub], 0
|
||||
mov [esi+usb_controller.ResettingPort], cl
|
||||
push ecx
|
||||
invoke GetTimerTicks
|
||||
pop ecx
|
||||
mov [esi+usb_controller.ResetTime], eax
|
||||
mov [esi+xhci_controller.ResetStart-XCD], eax
|
||||
call xhci_port_reg
|
||||
mov eax, [edx]
|
||||
test al, XHCI_PORT_PED
|
||||
jz .warm_reset
|
||||
mov [esi+usb_controller.ResettingStatus], 2
|
||||
DEBUGF 1,'K : XHCI %x: SS port %d link is up, PORTSC=%x\n',esi,ecx,eax
|
||||
jmp .nothing
|
||||
.warm_reset:
|
||||
; Connected, but the link has not come up. The Port Reset bit is set while a
|
||||
; warm reset is running, so the ordinary reset-wait machinery in
|
||||
; xhci_port_reset_done serves this case unchanged; the extra WRC change bit is
|
||||
; acknowledged there together with the usual ones.
|
||||
mov dword [edx], XHCI_PORT_PP + XHCI_PORT_WPR
|
||||
mov [esi+usb_controller.ResettingStatus], 1
|
||||
DEBUGF 1,'K : XHCI %x: warm-resetting port %d, PORTSC=%x\n',esi,ecx,eax
|
||||
.nothing:
|
||||
pop edx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; The kernel restarts pending root ports through the NewPortReset entry of
|
||||
; usb_hardware_func directly, bypassing xhci_new_port; SuperSpeed ports must
|
||||
; not get the USB2 reset on that path either, so the entry points here.
|
||||
; in: esi -> usb_controller, ecx = port index.
|
||||
proc xhci_ss_port_reset
|
||||
bt [esi+xhci_controller.SSPortMask-XCD], ecx
|
||||
jnc xhci_new_port.reset
|
||||
call xhci_ss_start_port
|
||||
ret
|
||||
endp
|
||||
|
||||
; =============================================================================
|
||||
; ===================== Endpoint Companion descriptors ========================
|
||||
; =============================================================================
|
||||
|
||||
; Reads the SuperSpeed Endpoint Companion descriptor of a bulk endpoint and
|
||||
; keeps its bMaxBurst for the Endpoint Context, allowing bursts of up to
|
||||
; bMaxBurst+1 packets per transaction. Zero (no bursts) is always legal, so
|
||||
; any failure just leaves the field alone. Only bulk endpoints are considered:
|
||||
; a nonzero burst on a periodic endpoint would also require the Max ESIT
|
||||
; Payload fields, and real interrupt endpoints do not burst anyway.
|
||||
; Relies on the stack frame of usb_open_pipe exactly like xhci_init_pipe does:
|
||||
; [ebp+8] is the config pipe of the device.
|
||||
; in: ebx -> xhci_pipe of a non-control endpoint being opened.
|
||||
proc xhci_ss_get_burst
|
||||
push eax ecx edx edi
|
||||
; 1. Only SuperSpeed bulk endpoints are of interest.
|
||||
cmp [ebx+xhci_pipe.PSIV], XHCI_PSI_SS
|
||||
jb .nothing
|
||||
mov eax, [ebx+xhci_pipe.EpType]
|
||||
and al, 3
|
||||
cmp al, 2 ; bulk endpoint types are 2 and 6
|
||||
jnz .nothing
|
||||
; 2. Find the configuration data kept by the kernel behind the device
|
||||
; descriptor; it holds the endpoint descriptors with their companions.
|
||||
mov eax, [ebp+8]
|
||||
mov eax, [eax+usb_pipe.DeviceData]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
movzx edx, [eax+usb_device_data.DeviceDescrSize]
|
||||
mov edi, [eax+usb_device_data.ConfigDataSize]
|
||||
lea ecx, [eax+edx+usb_device_data.DeviceDescriptor]
|
||||
add edi, ecx ; edi -> end of the configuration data
|
||||
; 3. Reconstruct bEndpointAddress from the Device Context Index.
|
||||
mov edx, [ebx+xhci_pipe.DCI]
|
||||
shr edx, 1
|
||||
test [ebx+xhci_pipe.Flags], XHCI_PIPE_IN
|
||||
jz @f
|
||||
or dl, 80h
|
||||
@@:
|
||||
; 4. Walk the descriptors to the one of this endpoint.
|
||||
.walk:
|
||||
lea eax, [ecx+2]
|
||||
cmp eax, edi
|
||||
ja .nothing
|
||||
movzx eax, byte [ecx] ; bLength
|
||||
test eax, eax
|
||||
jz .nothing ; malformed data, stop
|
||||
cmp byte [ecx+1], 5 ; an endpoint descriptor?
|
||||
jnz .advance
|
||||
cmp [ecx+2], dl ; bEndpointAddress
|
||||
jnz .advance
|
||||
; 5. The companion descriptor (type 30h) immediately follows its endpoint.
|
||||
add ecx, eax
|
||||
lea eax, [ecx+3]
|
||||
cmp eax, edi
|
||||
ja .nothing
|
||||
cmp byte [ecx+1], 30h ; SuperSpeed Endpoint Companion
|
||||
jnz .nothing
|
||||
movzx eax, byte [ecx+2] ; bMaxBurst
|
||||
cmp eax, 15
|
||||
ja .nothing
|
||||
mov [ebx+xhci_pipe.MaxBurst], eax
|
||||
DEBUGF 1,'K : XHCI: slot %d dci %d bursts %d+1 packets\n',[ebx+xhci_pipe.SlotId],[ebx+xhci_pipe.DCI],eax
|
||||
jmp .nothing
|
||||
.advance:
|
||||
add ecx, eax
|
||||
jmp .walk
|
||||
.nothing:
|
||||
pop edi edx ecx eax
|
||||
ret
|
||||
endp
|
||||
@@ -48,6 +48,10 @@ dtext:
|
||||
add esp, 28
|
||||
ret
|
||||
|
||||
.nomem:
|
||||
add esp, 40
|
||||
ret
|
||||
|
||||
.redirect:
|
||||
mov ebp, [edi]
|
||||
add edi, 8
|
||||
@@ -81,6 +85,8 @@ dtext:
|
||||
mov [esp+32], eax
|
||||
imul ebp, eax
|
||||
stdcall kernel_alloc, ebp
|
||||
test eax, eax
|
||||
jz .nomem
|
||||
mov ecx, ebp
|
||||
shr ecx, 2
|
||||
mov [esp+36], eax
|
||||
|
||||
@@ -2124,11 +2124,11 @@ socket_free:
|
||||
mov ebx, eax
|
||||
cmp [eax + STREAM_SOCKET.rcv.start_ptr], 0
|
||||
je @f
|
||||
stdcall free_kernel_space, [eax + STREAM_SOCKET.rcv.start_ptr]
|
||||
stdcall kernel_free, [eax + STREAM_SOCKET.rcv.start_ptr]
|
||||
@@:
|
||||
cmp [ebx + STREAM_SOCKET.snd.start_ptr], 0
|
||||
je @f
|
||||
stdcall free_kernel_space, [ebx + STREAM_SOCKET.snd.start_ptr]
|
||||
stdcall kernel_free, [ebx + STREAM_SOCKET.snd.start_ptr]
|
||||
@@:
|
||||
mov eax, ebx
|
||||
.no_stream:
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
@fasm free3d04.asm free3d04
|
||||
if not exist free3d04 ( @pause )
|
||||
@@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en_US >lang.inc
|
||||
@fasm free3d04.asm free3d04
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru_RU >lang.inc
|
||||
@fasm free3d04.asm free3d04
|
||||
@erase lang.inc
|
||||
@pause
|
||||
@@ -9,9 +9,10 @@
|
||||
;
|
||||
; Compile with FASM for Menuet (requires .INC files - see DATA Section)
|
||||
;
|
||||
; Willow - greatly srinked code size by using GIF texture and FPU to calculate sine table
|
||||
; Willow - greatly srinked code size by using packed texture and FPU to calculate sine table
|
||||
;
|
||||
; !!!! Don't use GIF_LITE.INC in your apps - it's modified for FREE3D !!!!
|
||||
; Textures are stored as a single 64x512 PNG embedded into the binary and
|
||||
; decoded at startup with libimg.
|
||||
;
|
||||
; Heavyiron - new 0-function of drawing window from kolibri (do not work correctly with menuet)
|
||||
|
||||
@@ -38,15 +39,17 @@ use32
|
||||
dd APP_MEM;0x100000 ; memory for app
|
||||
dd APP_MEM;0x100000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Icon
|
||||
include 'lang.inc'
|
||||
include '..\..\macros.inc'
|
||||
COLOR_ORDER equ OTHER
|
||||
include 'gif_lite.inc'
|
||||
include '..\..\proc32.inc'
|
||||
include '..\..\dll.inc'
|
||||
include '..\..\develop\libraries\libs-dev\libimg\libimg.inc'
|
||||
|
||||
START: ; start of execution
|
||||
mov esi,textures
|
||||
mov edi,ceil-8
|
||||
call ReadGIF
|
||||
mcall 68,11 ; init heap, libimg needs it
|
||||
stdcall dll.Load,@IMPORT
|
||||
test eax,eax
|
||||
jnz finish
|
||||
call load_textures
|
||||
mov esi,sinus
|
||||
mov ecx,360*10
|
||||
fninit
|
||||
@@ -291,6 +294,34 @@ m_right: ; turn right
|
||||
mcall
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* LOAD TEXTURES ********
|
||||
; *********************************************
|
||||
; Decodes the embedded 64x512 PNG (8 stacked 64x64 tiles) into the raw
|
||||
; 0x00RRGGBB texture bank at [ceil].
|
||||
|
||||
load_textures:
|
||||
invoke img.decode,textures,textures.size,0
|
||||
test eax,eax
|
||||
jz finish
|
||||
mov ebx,eax
|
||||
invoke img.convert,ebx,0,Image.bpp32,0,0
|
||||
push eax
|
||||
invoke img.destroy,ebx
|
||||
pop ebx
|
||||
test ebx,ebx
|
||||
jz finish
|
||||
mov esi,[ebx+Image.Data]
|
||||
mov edi,ceil
|
||||
mov ecx,TEX_SIZE*8/4
|
||||
.copy:
|
||||
lodsd
|
||||
and eax,0x00FFFFFF ; drop alpha, the renderer stores 32 bit dwords
|
||||
stosd ; into a 24 bit image buffer
|
||||
loop .copy
|
||||
invoke img.destroy,ebx
|
||||
ret
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
@@ -980,13 +1011,21 @@ dd 0x0001FFFF ; initial player position * 0xFFFF
|
||||
vpy:
|
||||
dd 0x0001FFFF
|
||||
|
||||
title db 'FISHEYE RAYCASTING ENGINE ETC. FREE3D',0
|
||||
title db 'Fisheye Raycasting Engine Etc. FREE3D',0
|
||||
|
||||
sindegree dd 0.0
|
||||
sininc dd 0.0017453292519943295769236907684886
|
||||
sindiv dd 6553.5
|
||||
textures:
|
||||
file 'texture.gif'
|
||||
file 'texture.png'
|
||||
.size = $ - textures
|
||||
|
||||
align 16
|
||||
@IMPORT:
|
||||
|
||||
library libimg , 'libimg.obj'
|
||||
|
||||
import libimg , libimg.init , 'lib_init' , img.decode , 'img_decode' , img.convert , 'img_convert', img.destroy , 'img_destroy'
|
||||
|
||||
align 4
|
||||
|
||||
|
||||
@@ -1,487 +0,0 @@
|
||||
; GIF LITE v3.0 by Willow
|
||||
; Written in pure assembler by Ivushkin Andrey aka Willow
|
||||
; Modified by Diamond
|
||||
;
|
||||
; This include file will contain functions to handle GIF image format
|
||||
;
|
||||
; Created: August 15, 2004
|
||||
; Last changed: June 24, 2007
|
||||
|
||||
; Requires kglobals.inc (iglobal/uglobal macro)
|
||||
; (program must 'include "kglobals.inc"' and say 'IncludeUGlobal'
|
||||
; somewhere in uninitialized data area).
|
||||
|
||||
; Configuration: [changed from program which includes this file]
|
||||
; 1. The constant COLOR_ORDER: must be one of
|
||||
; PALETTE - for 8-bit image with palette (sysfunction 65)
|
||||
; MENUETOS - for MenuetOS and KolibriOS color order (sysfunction 7)
|
||||
; OTHER - for standard color order
|
||||
; 2. Define constant GIF_SUPPORT_INTERLACED if you want to support interlaced
|
||||
; GIFs.
|
||||
; 3. Single image mode vs multiple image mode:
|
||||
; if the program defines the variable 'gif_img_count' of type dword
|
||||
; somewhere, ReadGIF will enter multiple image mode: gif_img_count
|
||||
; will be initialized with image count, output format is GIF_list,
|
||||
; the function GetGIFinfo retrieves Nth image info. Otherwise, ReadGIF
|
||||
; uses single image mode: exit after end of first image, output is
|
||||
; <dd width,height, times width*height[*3] db image>
|
||||
|
||||
if ~ (COLOR_ORDER in <PALETTE,MENUETOS,OTHER>)
|
||||
; This message may not appear under MenuetOS, so watch...
|
||||
display 'Please define COLOR_ORDER: PALETTE, MENUETOS or OTHER',13,10
|
||||
end if
|
||||
|
||||
if defined gif_img_count
|
||||
; virtual structure, used internally
|
||||
|
||||
struct GIF_list
|
||||
NextImg rd 1
|
||||
Left rw 1
|
||||
Top rw 1
|
||||
Width rw 1
|
||||
Height rw 1
|
||||
Delay rd 1
|
||||
Displacement rd 1 ; 0 = not specified
|
||||
; 1 = do not dispose
|
||||
; 2 = restore to background color
|
||||
; 3 = restore to previous
|
||||
if COLOR_ORDER eq PALETTE
|
||||
Image rd 1
|
||||
end if
|
||||
ends
|
||||
|
||||
struct GIF_info
|
||||
Left rw 1
|
||||
Top rw 1
|
||||
Width rw 1
|
||||
Height rw 1
|
||||
Delay rd 1
|
||||
Displacement rd 1
|
||||
if COLOR_ORDER eq PALETTE
|
||||
Palette rd 1
|
||||
end if
|
||||
ends
|
||||
|
||||
; ****************************************
|
||||
; FUNCTION GetGIFinfo - retrieve Nth image info
|
||||
; ****************************************
|
||||
; in:
|
||||
; esi - pointer to image list header
|
||||
; ecx - image_index (0...img_count-1)
|
||||
; edi - pointer to GIF_info structure to be filled
|
||||
|
||||
; out:
|
||||
; eax - pointer to RAW data, or 0, if error
|
||||
|
||||
GetGIFinfo:
|
||||
push esi ecx edi
|
||||
xor eax,eax
|
||||
jecxz .eloop
|
||||
.lp:
|
||||
mov esi,[esi]
|
||||
test esi,esi
|
||||
jz .error
|
||||
loop .lp
|
||||
.eloop:
|
||||
lodsd
|
||||
movsd
|
||||
movsd
|
||||
movsd
|
||||
movsd
|
||||
if COLOR_ORDER eq PALETTE
|
||||
lodsd
|
||||
mov [edi],esi
|
||||
else
|
||||
mov eax,esi
|
||||
end if
|
||||
.error:
|
||||
pop edi ecx esi
|
||||
ret
|
||||
|
||||
end if
|
||||
|
||||
_null fix 0x1000
|
||||
|
||||
; ****************************************
|
||||
; FUNCTION ReadGIF - unpacks GIF image
|
||||
; ****************************************
|
||||
; in:
|
||||
; esi - pointer to GIF file in memory
|
||||
; edi - pointer to output image list
|
||||
|
||||
; out:
|
||||
; eax - 0, all OK;
|
||||
; eax - 1, invalid signature;
|
||||
; eax >=8, unsupported image attributes
|
||||
;
|
||||
|
||||
ReadGIF:
|
||||
push esi edi
|
||||
mov [.cur_info],edi
|
||||
xor eax,eax
|
||||
mov [.globalColor],eax
|
||||
if defined gif_img_count
|
||||
mov [gif_img_count],eax
|
||||
mov [.anim_delay],eax
|
||||
mov [.anim_disp],eax
|
||||
end if
|
||||
inc eax
|
||||
cmp dword[esi],'GIF8'
|
||||
jne .ex ; signature
|
||||
mov ecx,[esi+0xa]
|
||||
add esi,0xd
|
||||
mov edi,esi
|
||||
test cl,cl
|
||||
jns .nextblock
|
||||
mov [.globalColor],esi
|
||||
call .Gif_skipmap
|
||||
.nextblock:
|
||||
cmp byte[edi],0x21
|
||||
jne .noextblock
|
||||
inc edi
|
||||
if defined gif_img_count
|
||||
cmp byte[edi],0xf9 ; Graphic Control Ext
|
||||
jne .no_gc
|
||||
movzx eax,word [edi+3]
|
||||
mov [.anim_delay],eax
|
||||
mov al,[edi+2]
|
||||
shr al,2
|
||||
and eax,7
|
||||
mov [.anim_disp],eax
|
||||
add edi,7
|
||||
jmp .nextblock
|
||||
.no_gc:
|
||||
end if
|
||||
inc edi
|
||||
.block_skip:
|
||||
movzx eax,byte[edi]
|
||||
lea edi,[edi+eax+1]
|
||||
test eax,eax
|
||||
jnz .block_skip
|
||||
jmp .nextblock
|
||||
.noextblock:
|
||||
mov al,8
|
||||
cmp byte[edi],0x2c ; image beginning
|
||||
jne .ex
|
||||
if defined gif_img_count
|
||||
inc [gif_img_count]
|
||||
end if
|
||||
inc edi
|
||||
mov esi,[.cur_info]
|
||||
if defined gif_img_count
|
||||
add esi,4
|
||||
end if
|
||||
xchg esi,edi
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
movzx ecx,word[esi+4]
|
||||
mov [.width],ecx
|
||||
movzx eax,word[esi+6]
|
||||
imul eax,ecx
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
lea eax,[eax*3]
|
||||
end if
|
||||
mov [.img_end],eax
|
||||
inc eax
|
||||
mov [.row_end],eax
|
||||
and [.pass],0
|
||||
test byte[esi+8],40h
|
||||
jz @f
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
lea ecx,[ecx*3]
|
||||
end if
|
||||
mov [.row_end],ecx
|
||||
@@:
|
||||
end if
|
||||
if defined gif_img_count
|
||||
movsd
|
||||
movsd
|
||||
mov eax,[.anim_delay]
|
||||
stosd
|
||||
mov eax,[.anim_disp]
|
||||
stosd
|
||||
else
|
||||
movzx eax,word[esi+4]
|
||||
stosd
|
||||
movzx eax,word[esi+6]
|
||||
stosd
|
||||
add esi,8
|
||||
end if
|
||||
push edi
|
||||
mov ecx,[esi]
|
||||
inc esi
|
||||
test cl,cl
|
||||
js .uselocal
|
||||
push [.globalColor]
|
||||
mov edi,esi
|
||||
jmp .setPal
|
||||
.uselocal:
|
||||
call .Gif_skipmap
|
||||
push esi
|
||||
.setPal:
|
||||
movzx ecx,byte[edi]
|
||||
inc ecx
|
||||
mov [.codesize],ecx
|
||||
dec ecx
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
pop [.Palette]
|
||||
end if
|
||||
lea esi,[edi+1]
|
||||
mov edi,.gif_workarea
|
||||
xor eax,eax
|
||||
lodsb ; eax - block_count
|
||||
add eax,esi
|
||||
mov [.block_ofs],eax
|
||||
mov [.bit_count],8
|
||||
mov eax,1
|
||||
shl eax,cl
|
||||
mov [.CC],eax
|
||||
mov ecx,eax
|
||||
inc eax
|
||||
mov [.EOI],eax
|
||||
mov eax, _null shl 16
|
||||
.filltable:
|
||||
stosd
|
||||
inc eax
|
||||
loop .filltable
|
||||
if COLOR_ORDER eq PALETTE
|
||||
pop eax
|
||||
pop edi
|
||||
push edi
|
||||
scasd
|
||||
push esi
|
||||
mov esi,eax
|
||||
mov ecx,[.CC]
|
||||
@@:
|
||||
lodsd
|
||||
dec esi
|
||||
bswap eax
|
||||
shr eax,8
|
||||
stosd
|
||||
loop @b
|
||||
pop esi
|
||||
pop eax
|
||||
mov [eax],edi
|
||||
else
|
||||
pop edi
|
||||
end if
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
mov [.img_start],edi
|
||||
add [.img_end],edi
|
||||
add [.row_end],edi
|
||||
end if
|
||||
.reinit:
|
||||
mov edx,[.EOI]
|
||||
inc edx
|
||||
push [.codesize]
|
||||
pop [.compsize]
|
||||
call .Gif_get_sym
|
||||
cmp eax,[.CC]
|
||||
je .reinit
|
||||
call .Gif_output
|
||||
.cycle:
|
||||
movzx ebx,ax
|
||||
call .Gif_get_sym
|
||||
cmp eax,edx
|
||||
jae .notintable
|
||||
cmp eax,[.CC]
|
||||
je .reinit
|
||||
cmp eax,[.EOI]
|
||||
je .end
|
||||
call .Gif_output
|
||||
.add:
|
||||
mov dword [.gif_workarea+edx*4],ebx
|
||||
cmp edx,0xFFF
|
||||
jae .cycle
|
||||
inc edx
|
||||
bsr ebx,edx
|
||||
cmp ebx,[.compsize]
|
||||
jne .noinc
|
||||
inc [.compsize]
|
||||
.noinc:
|
||||
jmp .cycle
|
||||
.notintable:
|
||||
push eax
|
||||
mov eax,ebx
|
||||
call .Gif_output
|
||||
push ebx
|
||||
movzx eax,bx
|
||||
call .Gif_output
|
||||
pop ebx eax
|
||||
jmp .add
|
||||
.end:
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
mov edi,[.img_end]
|
||||
end if
|
||||
if defined gif_img_count
|
||||
mov eax,[.cur_info]
|
||||
mov [eax],edi
|
||||
mov [.cur_info],edi
|
||||
add esi,2
|
||||
xchg esi,edi
|
||||
.nxt:
|
||||
cmp byte[edi],0
|
||||
jnz .continue
|
||||
inc edi
|
||||
jmp .nxt
|
||||
.continue:
|
||||
cmp byte[edi],0x3b
|
||||
jne .nextblock
|
||||
xchg esi,edi
|
||||
and dword [eax],0
|
||||
end if
|
||||
xor eax,eax
|
||||
.ex:
|
||||
pop edi esi
|
||||
ret
|
||||
|
||||
.Gif_skipmap:
|
||||
; in: ecx - image descriptor, esi - pointer to colormap
|
||||
; out: edi - pointer to area after colormap
|
||||
|
||||
and ecx,111b
|
||||
inc ecx ; color map size
|
||||
mov ebx,1
|
||||
shl ebx,cl
|
||||
lea ebx,[ebx*2+ebx]
|
||||
lea edi,[esi+ebx]
|
||||
ret
|
||||
|
||||
.Gif_get_sym:
|
||||
mov ecx,[.compsize]
|
||||
push ecx
|
||||
xor eax,eax
|
||||
.shift:
|
||||
ror byte[esi],1
|
||||
rcr eax,1
|
||||
dec [.bit_count]
|
||||
jnz .loop1
|
||||
inc esi
|
||||
cmp esi,[.block_ofs]
|
||||
jb .noblock
|
||||
push eax
|
||||
xor eax,eax
|
||||
lodsb
|
||||
test eax,eax
|
||||
jnz .nextbl
|
||||
mov eax,[.EOI]
|
||||
sub esi,2
|
||||
add esp,8
|
||||
jmp .exx
|
||||
.nextbl:
|
||||
add eax,esi
|
||||
mov [.block_ofs],eax
|
||||
pop eax
|
||||
.noblock:
|
||||
mov [.bit_count],8
|
||||
.loop1:
|
||||
loop .shift
|
||||
pop ecx
|
||||
rol eax,cl
|
||||
.exx:
|
||||
xor ecx,ecx
|
||||
ret
|
||||
|
||||
.Gif_output:
|
||||
push esi eax edx
|
||||
mov edx,.gif_workarea
|
||||
.next:
|
||||
push word[edx+eax*4]
|
||||
mov ax,word[edx+eax*4+2]
|
||||
inc ecx
|
||||
cmp ax,_null
|
||||
jnz .next
|
||||
shl ebx,16
|
||||
mov bx,[esp]
|
||||
.loop2:
|
||||
pop ax
|
||||
|
||||
if COLOR_ORDER eq PALETTE
|
||||
stosb
|
||||
else
|
||||
lea esi,[eax+eax*2]
|
||||
add esi,[.Palette]
|
||||
|
||||
if COLOR_ORDER eq MENUETOS
|
||||
mov esi,[esi]
|
||||
bswap esi
|
||||
shr esi,8
|
||||
mov [edi],esi
|
||||
add edi,3
|
||||
else
|
||||
movsb
|
||||
movsb
|
||||
movsb
|
||||
mov byte [edi],0
|
||||
inc edi
|
||||
end if
|
||||
end if
|
||||
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
cmp edi,[.row_end]
|
||||
jb .norowend
|
||||
mov eax,[.width]
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
lea eax,[eax*3]
|
||||
end if
|
||||
push eax
|
||||
sub edi,eax
|
||||
add eax,eax
|
||||
cmp [.pass],3
|
||||
jz @f
|
||||
add eax,eax
|
||||
cmp [.pass],2
|
||||
jz @f
|
||||
add eax,eax
|
||||
@@:
|
||||
add edi,eax
|
||||
pop eax
|
||||
cmp edi,[.img_end]
|
||||
jb .nextrow
|
||||
mov edi,[.img_start]
|
||||
inc [.pass]
|
||||
add edi,eax
|
||||
cmp [.pass],3
|
||||
jz @f
|
||||
add edi,eax
|
||||
cmp [.pass],2
|
||||
jz @f
|
||||
add edi,eax
|
||||
add edi,eax
|
||||
@@:
|
||||
.nextrow:
|
||||
add eax,edi
|
||||
mov [.row_end],eax
|
||||
xor eax,eax
|
||||
.norowend:
|
||||
end if
|
||||
|
||||
loop .loop2
|
||||
pop edx eax esi
|
||||
ret
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
ReadGIF.globalColor rd 1
|
||||
ReadGIF.cur_info rd 1 ; image table pointer
|
||||
ReadGIF.codesize rd 1
|
||||
ReadGIF.compsize rd 1
|
||||
ReadGIF.bit_count rd 1
|
||||
ReadGIF.CC rd 1
|
||||
ReadGIF.EOI rd 1
|
||||
if ~(COLOR_ORDER eq PALETTE)
|
||||
ReadGIF.Palette rd 1
|
||||
end if
|
||||
ReadGIF.block_ofs rd 1
|
||||
if defined GIF_SUPPORT_INTERLACED
|
||||
ReadGIF.row_end rd 1
|
||||
ReadGIF.img_end rd 1
|
||||
ReadGIF.img_start rd 1
|
||||
ReadGIF.pass rd 1
|
||||
ReadGIF.width rd 1
|
||||
end if
|
||||
if defined gif_img_count
|
||||
ReadGIF.anim_delay rd 1
|
||||
ReadGIF.anim_disp rd 1
|
||||
end if
|
||||
ReadGIF.gif_workarea rb 16*1024
|
||||
endg
|
||||
@@ -10,11 +10,11 @@ By Dieter Marfurt
|
||||
|
||||
--------------------------------------------
|
||||
|
||||
Format of texture include files:
|
||||
Format of the texture file:
|
||||
|
||||
dd 0x00RRGGBB,0x00RRGGBB....
|
||||
|
||||
for 64*64 pixels.
|
||||
texture.png - a 64*512 image holding the 8 textures of 64*64 pixels
|
||||
stacked vertically. It is embedded into the binary and decoded at
|
||||
startup with libimg.
|
||||
|
||||
Have fun!
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 14 KiB |
@@ -5,7 +5,7 @@ void shell_cls()
|
||||
__shell_init();
|
||||
if (__shell_is_init == __SHELL_INIT_OK)
|
||||
{
|
||||
*__shell_shm = SHELL_CLS;
|
||||
__shell_shm->cmd = SHELL_CLS;
|
||||
__SHELL_WAIT();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ void shell_exit()
|
||||
{
|
||||
if (__shell_is_init == __SHELL_INIT_OK)
|
||||
{
|
||||
*__shell_shm = SHELL_EXIT;
|
||||
__shell_shm->cmd = SHELL_EXIT;
|
||||
__SHELL_WAIT();
|
||||
_ksys_shm_close(__shell_shm_name);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ unsigned shell_get_pid()
|
||||
__shell_init();
|
||||
if (__shell_is_init == __SHELL_INIT_OK)
|
||||
{
|
||||
*__shell_shm = SHELL_PID;
|
||||
__shell_shm->cmd = SHELL_PID;
|
||||
__SHELL_WAIT();
|
||||
memcpy(&pid, __shell_shm + 1, sizeof(unsigned));
|
||||
memcpy(&pid, __shell_shm->data, sizeof(unsigned));
|
||||
}
|
||||
|
||||
return pid;
|
||||
|
||||
@@ -6,10 +6,10 @@ char shell_getc()
|
||||
|
||||
if (__shell_is_init == __SHELL_INIT_OK)
|
||||
{
|
||||
*__shell_shm = SHELL_GETC;
|
||||
__shell_shm->cmd = SHELL_GETC;
|
||||
__SHELL_WAIT();
|
||||
|
||||
return *(__shell_shm + 1);
|
||||
return __shell_shm->data[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -7,9 +7,9 @@ void shell_gets(char *str, int n)
|
||||
|
||||
if (__shell_is_init == __SHELL_INIT_OK)
|
||||
{
|
||||
*__shell_shm = SHELL_GETS;
|
||||
__shell_shm->cmd = SHELL_GETS;
|
||||
__SHELL_WAIT();
|
||||
|
||||
strncpy(str, __shell_shm + 1, n);
|
||||
strncpy(str, __shell_shm->data, n);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
char app_name[13];
|
||||
char __shell_shm_name[32];
|
||||
char *__shell_shm = NULL;
|
||||
struct shell_shm_buffer *__shell_shm = NULL;
|
||||
enum __SHELL_INIT_STATE __shell_is_init = __SHELL_NOT_LOADED;
|
||||
|
||||
int __shell_shm_init()
|
||||
@@ -17,12 +17,12 @@ int __shell_shm_init()
|
||||
|
||||
_ksys_thread_info(&proc_info, -1);
|
||||
PID = proc_info.pid;
|
||||
strncpy(app_name, (&proc_info)->name, 12);
|
||||
strncpy(app_name, proc_info.name, sizeof(app_name) - 1);
|
||||
|
||||
itoa(PID, __shell_shm_name);
|
||||
strcat(__shell_shm_name, "-SHELL");
|
||||
|
||||
return _ksys_shm_open(__shell_shm_name, KSYS_SHM_OPEN_ALWAYS | KSYS_SHM_WRITE, SHELL_SHM_MAX, &__shell_shm);
|
||||
return _ksys_shm_open(__shell_shm_name, KSYS_SHM_OPEN_ALWAYS | KSYS_SHM_WRITE, sizeof(*__shell_shm), (char **)&__shell_shm);
|
||||
}
|
||||
|
||||
void __shell_init()
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
int shell_ping()
|
||||
{
|
||||
*__shell_shm = SHELL_PING;
|
||||
__shell_shm->cmd = SHELL_PING;
|
||||
|
||||
_ksys_thread_yield(); // hope shell is fast enough
|
||||
|
||||
size_t i = 0;
|
||||
while (*__shell_shm != SHELL_OK)
|
||||
while (__shell_shm->cmd != SHELL_OK)
|
||||
{
|
||||
if (i > (SHELL_PING_TIMEOUT / SHELL_PING_MIN_DELAY))
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ void shell_printf(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf(__shell_shm + 1, SHELL_SHM_MAX, format, ap);
|
||||
*__shell_shm = SHELL_PUTS;
|
||||
vsnprintf(__shell_shm->data, sizeof(__shell_shm->data), format, ap);
|
||||
__shell_shm->cmd = SHELL_PUTS;
|
||||
va_end(ap);
|
||||
__SHELL_WAIT();
|
||||
}
|
||||
@@ -6,8 +6,8 @@ void shell_putc(char c)
|
||||
|
||||
if (__shell_is_init == __SHELL_INIT_OK)
|
||||
{
|
||||
*(__shell_shm + 1) = c;
|
||||
*__shell_shm = SHELL_PUTC;
|
||||
__shell_shm->data[0] = c;
|
||||
__shell_shm->cmd = SHELL_PUTC;
|
||||
__SHELL_WAIT();
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,16 @@ void shell_write_string(const char *s, size_t len)
|
||||
__shell_init();
|
||||
if (__shell_is_init == __SHELL_INIT_OK)
|
||||
{
|
||||
if (len > SHELL_SHM_MAX - 1)
|
||||
if (len > sizeof(__shell_shm->data) - 1)
|
||||
{
|
||||
shell_write_string(s, SHELL_SHM_MAX - 1); // Outputs as much as it can.
|
||||
shell_write_string(s + (SHELL_SHM_MAX - 1), len - (SHELL_SHM_MAX - 1)); // Outputs the rest.
|
||||
shell_write_string(s, sizeof(__shell_shm->data) - 1); // Outputs as much as it can.
|
||||
shell_write_string(s + (sizeof(__shell_shm->data) - 1), len - (sizeof(__shell_shm->data) - 1)); // Outputs the rest.
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(__shell_shm, 0, SHELL_SHM_MAX); // without int shell show \t, \n, lose chars and other trash
|
||||
memcpy(__shell_shm + 1, s, len);
|
||||
*__shell_shm = SHELL_PUTS;
|
||||
memset(__shell_shm->data, 0, sizeof(__shell_shm->data)); // without int shell show \t, \n, lose chars and other trash
|
||||
memcpy(__shell_shm->data, s, len);
|
||||
__shell_shm->cmd = SHELL_PUTS;
|
||||
__SHELL_WAIT();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,17 @@
|
||||
#define __EXTERN extern
|
||||
#endif
|
||||
|
||||
#define SHELL_OK 0
|
||||
#define SHELL_EXIT 1
|
||||
#define SHELL_PUTC 2
|
||||
#define SHELL_PUTS 3
|
||||
#define SHELL_GETC 4
|
||||
#define SHELL_GETS 5
|
||||
#define SHELL_CLS 6
|
||||
#define SHELL_PID 7
|
||||
#define SHELL_PING 8
|
||||
enum SHELL_API_COMMANDS {
|
||||
SHELL_OK = 0,
|
||||
SHELL_EXIT = 1,
|
||||
SHELL_PUTC = 2,
|
||||
SHELL_PUTS = 3,
|
||||
SHELL_GETC = 4,
|
||||
SHELL_GETS = 5,
|
||||
SHELL_CLS = 6,
|
||||
SHELL_PID = 7,
|
||||
SHELL_PING = 8
|
||||
};
|
||||
|
||||
#define SHELL_SHM_MAX 1024 * 16
|
||||
|
||||
@@ -28,15 +30,22 @@ enum __SHELL_INIT_STATE {
|
||||
__SHELL_INIT_FAILED = 3 // fail init shell
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct shell_shm_buffer {
|
||||
uint8_t cmd;
|
||||
char data[SHELL_SHM_MAX - sizeof(((struct shell_shm_buffer*)NULL)->cmd)];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
__EXTERN char __shell_shm_name[32];
|
||||
__EXTERN char* __shell_shm;
|
||||
__EXTERN struct shell_shm_buffer* __shell_shm;
|
||||
__EXTERN enum __SHELL_INIT_STATE __shell_is_init;
|
||||
__EXTERN void __shell_init();
|
||||
|
||||
#define __SHELL_WAIT() \
|
||||
do { \
|
||||
_ksys_thread_yield(); \
|
||||
} while (*__shell_shm);
|
||||
} while (__shell_shm->cmd);
|
||||
|
||||
__EXTERN int shell_ping();
|
||||
__EXTERN unsigned shell_get_pid();
|
||||
@@ -52,4 +61,5 @@ __EXTERN void shell_printf(const char* format, ...);
|
||||
__EXTERN void shell_write_string(const char* s, size_t len);
|
||||
|
||||
__EXTERN void shell_cls();
|
||||
|
||||
#endif
|
||||
@@ -913,7 +913,7 @@ static off_t get_fileinfo(struct reader *rds,char *buf)
|
||||
#define syncsafe_to_long(buf,res) \
|
||||
( \
|
||||
(((buf)[0]|(buf)[1]|(buf)[2]|(buf)[3]) & 0x80) ? 0 : \
|
||||
(res = (((unsigned long) (buf)[0]) << 27) \
|
||||
(res = (((unsigned long) (buf)[0]) << 21) \
|
||||
| (((unsigned long) (buf)[1]) << 14) \
|
||||
| (((unsigned long) (buf)[2]) << 7) \
|
||||
| ((unsigned long) (buf)[3]) \
|
||||
|
||||
@@ -1,262 +1,268 @@
|
||||
driverlist:
|
||||
db 'RTL8139',0 ; Realtek 8139
|
||||
dd 0x813910ec
|
||||
dd 0x813810ec
|
||||
dd 0x12111113
|
||||
dd 0x13601500
|
||||
dd 0x13604033
|
||||
dd 0x13001186
|
||||
dd 0x13401186
|
||||
dd 0xab0613d1
|
||||
dd 0xa1171259
|
||||
dd 0xa11e1259
|
||||
dd 0xab0614ea
|
||||
dd 0xab0714ea
|
||||
dd 0x123411db
|
||||
dd 0x91301432
|
||||
dd 0x101202ac
|
||||
dd 0x0106018a
|
||||
dd 0x1211126c
|
||||
dd 0x81391743
|
||||
dd 0x8139021b
|
||||
dd 0x0 ; end
|
||||
|
||||
db 'RTL8029',0 ; Realtek 8029 (PCI NE2000)
|
||||
dd 0x802910ec
|
||||
dd 0x0
|
||||
|
||||
db 'I8255X',0 ; Intel eepro100
|
||||
dd 0x10298086
|
||||
dd 0x10308086
|
||||
;dd 0x10318086
|
||||
;dd 0x10328086
|
||||
;dd 0x10338086
|
||||
;dd 0x10348086
|
||||
;dd 0x10388086
|
||||
dd 0x10398086
|
||||
;dd 0x103A8086
|
||||
;dd 0x103B8086
|
||||
;dd 0x103C8086
|
||||
;dd 0x103D8086
|
||||
;dd 0x103E8086
|
||||
;dd 0x10508086
|
||||
;dd 0x10518086
|
||||
;dd 0x10528086
|
||||
;dd 0x10538086
|
||||
;dd 0x10548086
|
||||
;dd 0x10558086
|
||||
;dd 0x10568086
|
||||
;dd 0x10578086
|
||||
;dd 0x10598086
|
||||
;dd 0x10648086
|
||||
;dd 0x10658086
|
||||
;dd 0x10668086
|
||||
;dd 0x10678086
|
||||
dd 0x10688086
|
||||
;dd 0x10698086
|
||||
;dd 0x106A8086
|
||||
;dd 0x106B8086
|
||||
;dd 0x10918086
|
||||
;dd 0x10928086
|
||||
;dd 0x10938086
|
||||
;dd 0x10948086
|
||||
;dd 0x10958086
|
||||
;dd 0x10fe8086
|
||||
dd 0x12098086
|
||||
dd 0x12298086
|
||||
dd 0x24498086
|
||||
;dd 0x24598086
|
||||
;dd 0x245D8086
|
||||
;dd 0x27DC8086
|
||||
dd 0x0
|
||||
|
||||
db 'RTL8169',0 ; Realtek 8169
|
||||
dd 0x816710ec
|
||||
dd 0x816810ec
|
||||
dd 0x816910ec
|
||||
dd 0x011616ec
|
||||
dd 0x43001186
|
||||
dd 0x813610ec
|
||||
dd 0x0
|
||||
|
||||
db '3C59X',0 ; 3Com 59x
|
||||
dd 0x590010b7
|
||||
dd 0x592010b7
|
||||
dd 0x597010b7
|
||||
dd 0x595010b7
|
||||
dd 0x595110b7
|
||||
dd 0x595210b7
|
||||
dd 0x900010b7
|
||||
dd 0x900110b7
|
||||
dd 0x900410b7
|
||||
dd 0x900510b7
|
||||
dd 0x900610b7
|
||||
dd 0x900A10b7
|
||||
dd 0x905010b7
|
||||
dd 0x905110b7
|
||||
dd 0x905510b7
|
||||
dd 0x905810b7
|
||||
dd 0x905A10b7
|
||||
dd 0x920010b7
|
||||
dd 0x980010b7
|
||||
dd 0x980510b7
|
||||
dd 0x764610b7
|
||||
dd 0x505510b7
|
||||
dd 0x605510b7
|
||||
dd 0x605610b7
|
||||
dd 0x5b5710b7
|
||||
dd 0x505710b7
|
||||
dd 0x515710b7
|
||||
dd 0x525710b7
|
||||
dd 0x656010b7
|
||||
dd 0x656210b7
|
||||
dd 0x656410b7
|
||||
dd 0x450010b7
|
||||
dd 0x0
|
||||
|
||||
db 'SIS900',0
|
||||
dd 0x09001039
|
||||
dd 0x70161039
|
||||
dd 0x0
|
||||
|
||||
db 'PCNET32',0
|
||||
dd 0x20001022
|
||||
dd 0x26251022
|
||||
dd 0x20011022
|
||||
dd 0x0
|
||||
|
||||
db 'FORCEDETH',0 ; nVidia nForce
|
||||
dd 0x006610de
|
||||
dd 0x01c310de
|
||||
dd 0x00D610de
|
||||
dd 0x008610de
|
||||
dd 0x008c10de
|
||||
dd 0x00e610de
|
||||
dd 0x00df10de
|
||||
dd 0x005610de
|
||||
dd 0x005710de
|
||||
dd 0x003710de
|
||||
dd 0x003810de
|
||||
dd 0x026810de
|
||||
dd 0x026910de
|
||||
dd 0x037210de
|
||||
dd 0x037310de
|
||||
dd 0x03e510de
|
||||
dd 0x03e610de
|
||||
dd 0x03ee10de
|
||||
dd 0x03ef10de
|
||||
dd 0x045010de
|
||||
dd 0x045110de
|
||||
dd 0x045210de
|
||||
dd 0x045310de
|
||||
dd 0x054c10de
|
||||
dd 0x054d10de
|
||||
dd 0x054e10de
|
||||
dd 0x054f10de
|
||||
dd 0x07dc10de
|
||||
dd 0x07dd10de
|
||||
dd 0x07de10de
|
||||
dd 0x07df10de
|
||||
dd 0x076010de
|
||||
dd 0x076110de
|
||||
dd 0x076210de
|
||||
dd 0x076310de
|
||||
dd 0x0ab010de
|
||||
dd 0x0ab110de
|
||||
dd 0x0ab210de
|
||||
dd 0x0ab310de
|
||||
dd 0x0d7d10de
|
||||
dd 0x0
|
||||
|
||||
db 'MTD80X',0 ; Myson / Surecom
|
||||
dd 0x08031516
|
||||
dd 0x08001516
|
||||
dd 0x08911516
|
||||
dd 0x0
|
||||
|
||||
db 'DEC21X4X',0
|
||||
dd 0x00021011
|
||||
dd 0x00091011
|
||||
dd 0x00141011
|
||||
dd 0x00191011
|
||||
dd 0x000211AD
|
||||
dd 0x051210D9
|
||||
dd 0x053110D9
|
||||
dd 0x1400125B
|
||||
dd 0x09851317
|
||||
dd 0x0
|
||||
|
||||
db 'R6040',0 ; eBox integrated network
|
||||
dd 0x604017F3
|
||||
dd 0x0
|
||||
|
||||
db 'I8254X',0
|
||||
dd 0x10008086 ; 82542 (Fiber)
|
||||
dd 0x10018086 ; 82543GC (Fiber)
|
||||
dd 0x10048086 ; 82543GC (Copper)
|
||||
dd 0x10088086 ; 82544EI (Copper)
|
||||
dd 0x10098086 ; 82544EI (Fiber)
|
||||
dd 0x100A8086 ; 82540EM
|
||||
dd 0x100C8086 ; 82544GC (Copper)
|
||||
dd 0x100D8086 ; 82544GC (LOM)
|
||||
dd 0x100E8086 ; 82540EM
|
||||
dd 0x100F8086 ; 82545EM (Copper)
|
||||
dd 0x10108086 ; 82546EB (Copper)
|
||||
dd 0x10118086 ; 82545EM (Fiber)
|
||||
dd 0x10128086 ; 82546EB (Fiber)
|
||||
dd 0x10138086 ; 82541EI
|
||||
dd 0x10148086 ; 82541ER
|
||||
dd 0x10158086 ; 82540EM (LOM)
|
||||
dd 0x10168086 ; 82540EP (Mobile)
|
||||
dd 0x10178086 ; 82540EP
|
||||
dd 0x10188086 ; 82541EI
|
||||
dd 0x10198086 ; 82547EI
|
||||
dd 0x101a8086 ; 82547EI (Mobile)
|
||||
dd 0x101d8086 ; 82546EB
|
||||
dd 0x101e8086 ; 82540EP (Mobile)
|
||||
dd 0x10268086 ; 82545GM
|
||||
dd 0x10278086 ; 82545GM
|
||||
dd 0x10288086 ; 82545GM
|
||||
dd 0x105b8086 ; 82546GB (Copper)
|
||||
dd 0x10758086 ; 82547GI
|
||||
dd 0x10768086 ; 82541GI
|
||||
dd 0x10778086 ; 82541GI
|
||||
dd 0x10788086 ; 82541ER
|
||||
dd 0x10798086 ; 82546GB
|
||||
dd 0x107a8086 ; 82546GB
|
||||
dd 0x107b8086 ; 82546GB
|
||||
dd 0x107c8086 ; 82541PI
|
||||
dd 0x10b58086 ; 82546GB (Copper)
|
||||
dd 0x11078086 ; 82544EI
|
||||
dd 0x11128086 ; 82544GC
|
||||
dd 0x15A18086 ; I218-V
|
||||
dd 0x0
|
||||
|
||||
db 'RHINE', 0 ; VIA Rhine
|
||||
dd 0x30431106
|
||||
dd 0x61001106
|
||||
dd 0x30651106
|
||||
dd 0x31061106
|
||||
dd 0x30531106
|
||||
dd 0x0
|
||||
|
||||
|
||||
db 'AR81XX', 0
|
||||
dd 0x10631969 ; AR8131
|
||||
;dd 0x10621969 ; AR8132
|
||||
;dd 0x10731969 ; AR8151 V1
|
||||
;dd 0x10831969 ; AR8151 V2
|
||||
;dd 0x20601969 ; AR8152 V1
|
||||
dd 0x20621969 ; AR8152 V2
|
||||
dd 0x10911969 ; AR8161
|
||||
;dd 0xe0911969 ; E2200
|
||||
;dd 0xe0a11969 ; E2400
|
||||
;dd 0xe0b11969 ; E2500
|
||||
dd 0x10901969 ; AR8162
|
||||
dd 0x10A11969 ; AR8171 (QCA8171)
|
||||
dd 0x10A01969 ; AR8172 (QCA8172)
|
||||
|
||||
|
||||
dd 0x0
|
||||
|
||||
dd 0x0 ; driverlist end
|
||||
driverlist:
|
||||
db 'RTL8139',0 ; Realtek 8139
|
||||
dd 0x813910ec
|
||||
dd 0x813810ec
|
||||
dd 0x12111113
|
||||
dd 0x13601500
|
||||
dd 0x13604033
|
||||
dd 0x13001186
|
||||
dd 0x13401186
|
||||
dd 0xab0613d1
|
||||
dd 0xa1171259
|
||||
dd 0xa11e1259
|
||||
dd 0xab0614ea
|
||||
dd 0xab0714ea
|
||||
dd 0x123411db
|
||||
dd 0x91301432
|
||||
dd 0x101202ac
|
||||
dd 0x0106018a
|
||||
dd 0x1211126c
|
||||
dd 0x81391743
|
||||
dd 0x8139021b
|
||||
dd 0x0 ; end
|
||||
|
||||
db 'RTL8029',0 ; Realtek 8029 (PCI NE2000)
|
||||
dd 0x802910ec
|
||||
dd 0x0
|
||||
|
||||
db 'I8255X',0 ; Intel eepro100
|
||||
dd 0x10298086
|
||||
dd 0x10308086
|
||||
;dd 0x10318086
|
||||
;dd 0x10328086
|
||||
;dd 0x10338086
|
||||
;dd 0x10348086
|
||||
;dd 0x10388086
|
||||
dd 0x10398086
|
||||
;dd 0x103A8086
|
||||
;dd 0x103B8086
|
||||
;dd 0x103C8086
|
||||
;dd 0x103D8086
|
||||
;dd 0x103E8086
|
||||
;dd 0x10508086
|
||||
;dd 0x10518086
|
||||
;dd 0x10528086
|
||||
;dd 0x10538086
|
||||
;dd 0x10548086
|
||||
;dd 0x10558086
|
||||
;dd 0x10568086
|
||||
;dd 0x10578086
|
||||
;dd 0x10598086
|
||||
;dd 0x10648086
|
||||
;dd 0x10658086
|
||||
;dd 0x10668086
|
||||
;dd 0x10678086
|
||||
dd 0x10688086
|
||||
;dd 0x10698086
|
||||
;dd 0x106A8086
|
||||
;dd 0x106B8086
|
||||
;dd 0x10918086
|
||||
;dd 0x10928086
|
||||
;dd 0x10938086
|
||||
;dd 0x10948086
|
||||
;dd 0x10958086
|
||||
;dd 0x10fe8086
|
||||
dd 0x12098086
|
||||
dd 0x12298086
|
||||
dd 0x24498086
|
||||
;dd 0x24598086
|
||||
;dd 0x245D8086
|
||||
;dd 0x27DC8086
|
||||
dd 0x0
|
||||
|
||||
db 'RTL8169',0 ; Realtek 8169
|
||||
dd 0x816710ec
|
||||
dd 0x816810ec
|
||||
dd 0x816910ec
|
||||
dd 0x011616ec
|
||||
dd 0x43001186
|
||||
dd 0x813610ec
|
||||
dd 0x0
|
||||
|
||||
db '3C59X',0 ; 3Com 59x
|
||||
dd 0x590010b7
|
||||
dd 0x592010b7
|
||||
dd 0x597010b7
|
||||
dd 0x595010b7
|
||||
dd 0x595110b7
|
||||
dd 0x595210b7
|
||||
dd 0x900010b7
|
||||
dd 0x900110b7
|
||||
dd 0x900410b7
|
||||
dd 0x900510b7
|
||||
dd 0x900610b7
|
||||
dd 0x900A10b7
|
||||
dd 0x905010b7
|
||||
dd 0x905110b7
|
||||
dd 0x905510b7
|
||||
dd 0x905810b7
|
||||
dd 0x905A10b7
|
||||
dd 0x920010b7
|
||||
dd 0x980010b7
|
||||
dd 0x980510b7
|
||||
dd 0x764610b7
|
||||
dd 0x505510b7
|
||||
dd 0x605510b7
|
||||
dd 0x605610b7
|
||||
dd 0x5b5710b7
|
||||
dd 0x505710b7
|
||||
dd 0x515710b7
|
||||
dd 0x525710b7
|
||||
dd 0x656010b7
|
||||
dd 0x656210b7
|
||||
dd 0x656410b7
|
||||
dd 0x450010b7
|
||||
dd 0x0
|
||||
|
||||
db 'SIS900',0
|
||||
dd 0x09001039
|
||||
dd 0x70161039
|
||||
dd 0x0
|
||||
|
||||
db 'PCNET32',0
|
||||
dd 0x20001022
|
||||
dd 0x26251022
|
||||
dd 0x20011022
|
||||
dd 0x0
|
||||
|
||||
db 'FORCEDETH',0 ; nVidia nForce
|
||||
dd 0x006610de
|
||||
dd 0x01c310de
|
||||
dd 0x00D610de
|
||||
dd 0x008610de
|
||||
dd 0x008c10de
|
||||
dd 0x00e610de
|
||||
dd 0x00df10de
|
||||
dd 0x005610de
|
||||
dd 0x005710de
|
||||
dd 0x003710de
|
||||
dd 0x003810de
|
||||
dd 0x026810de
|
||||
dd 0x026910de
|
||||
dd 0x037210de
|
||||
dd 0x037310de
|
||||
dd 0x03e510de
|
||||
dd 0x03e610de
|
||||
dd 0x03ee10de
|
||||
dd 0x03ef10de
|
||||
dd 0x045010de
|
||||
dd 0x045110de
|
||||
dd 0x045210de
|
||||
dd 0x045310de
|
||||
dd 0x054c10de
|
||||
dd 0x054d10de
|
||||
dd 0x054e10de
|
||||
dd 0x054f10de
|
||||
dd 0x07dc10de
|
||||
dd 0x07dd10de
|
||||
dd 0x07de10de
|
||||
dd 0x07df10de
|
||||
dd 0x076010de
|
||||
dd 0x076110de
|
||||
dd 0x076210de
|
||||
dd 0x076310de
|
||||
dd 0x0ab010de
|
||||
dd 0x0ab110de
|
||||
dd 0x0ab210de
|
||||
dd 0x0ab310de
|
||||
dd 0x0d7d10de
|
||||
dd 0x0
|
||||
|
||||
db 'MTD80X',0 ; Myson / Surecom
|
||||
dd 0x08031516
|
||||
dd 0x08001516
|
||||
dd 0x08911516
|
||||
dd 0x0
|
||||
|
||||
db 'DEC21X4X',0
|
||||
dd 0x00021011
|
||||
dd 0x00091011
|
||||
dd 0x00141011
|
||||
dd 0x00191011
|
||||
dd 0x000211AD
|
||||
dd 0x051210D9
|
||||
dd 0x053110D9
|
||||
dd 0x1400125B
|
||||
dd 0x09851317
|
||||
dd 0x0
|
||||
|
||||
db 'R6040',0 ; eBox integrated network
|
||||
dd 0x604017F3
|
||||
dd 0x0
|
||||
|
||||
db 'I8254X',0
|
||||
dd 0x10008086 ; 82542 (Fiber)
|
||||
dd 0x10018086 ; 82543GC (Fiber)
|
||||
dd 0x10048086 ; 82543GC (Copper)
|
||||
dd 0x10088086 ; 82544EI (Copper)
|
||||
dd 0x10098086 ; 82544EI (Fiber)
|
||||
dd 0x100A8086 ; 82540EM
|
||||
dd 0x100C8086 ; 82544GC (Copper)
|
||||
dd 0x100D8086 ; 82544GC (LOM)
|
||||
dd 0x100E8086 ; 82540EM
|
||||
dd 0x100F8086 ; 82545EM (Copper)
|
||||
dd 0x10108086 ; 82546EB (Copper)
|
||||
dd 0x10118086 ; 82545EM (Fiber)
|
||||
dd 0x10128086 ; 82546EB (Fiber)
|
||||
dd 0x10138086 ; 82541EI
|
||||
dd 0x10148086 ; 82541ER
|
||||
dd 0x10158086 ; 82540EM (LOM)
|
||||
dd 0x10168086 ; 82540EP (Mobile)
|
||||
dd 0x10178086 ; 82540EP
|
||||
dd 0x10188086 ; 82541EI
|
||||
dd 0x10198086 ; 82547EI
|
||||
dd 0x101a8086 ; 82547EI (Mobile)
|
||||
dd 0x101d8086 ; 82546EB
|
||||
dd 0x101e8086 ; 82540EP (Mobile)
|
||||
dd 0x10268086 ; 82545GM
|
||||
dd 0x10278086 ; 82545GM
|
||||
dd 0x10288086 ; 82545GM
|
||||
dd 0x105b8086 ; 82546GB (Copper)
|
||||
dd 0x10758086 ; 82547GI
|
||||
dd 0x10768086 ; 82541GI
|
||||
dd 0x10778086 ; 82541GI
|
||||
dd 0x10788086 ; 82541ER
|
||||
dd 0x10798086 ; 82546GB
|
||||
dd 0x107a8086 ; 82546GB
|
||||
dd 0x107b8086 ; 82546GB
|
||||
dd 0x107c8086 ; 82541PI
|
||||
dd 0x10b58086 ; 82546GB (Copper)
|
||||
dd 0x11078086 ; 82544EI
|
||||
dd 0x11128086 ; 82544GC
|
||||
dd 0x15A18086 ; I218-V
|
||||
dd 0x0
|
||||
|
||||
db 'RHINE', 0 ; VIA Rhine
|
||||
dd 0x30431106
|
||||
dd 0x61001106
|
||||
dd 0x30651106
|
||||
dd 0x31061106
|
||||
dd 0x30531106
|
||||
dd 0x0
|
||||
|
||||
|
||||
db 'AR81XX', 0
|
||||
dd 0x10631969 ; AR8131
|
||||
;dd 0x10621969 ; AR8132
|
||||
;dd 0x10731969 ; AR8151 V1
|
||||
;dd 0x10831969 ; AR8151 V2
|
||||
;dd 0x20601969 ; AR8152 V1
|
||||
dd 0x20621969 ; AR8152 V2
|
||||
dd 0x10911969 ; AR8161
|
||||
;dd 0xe0911969 ; E2200
|
||||
;dd 0xe0a11969 ; E2400
|
||||
;dd 0xe0b11969 ; E2500
|
||||
dd 0x10901969 ; AR8162
|
||||
dd 0x10A11969 ; AR8171 (QCA8171)
|
||||
dd 0x10A01969 ; AR8172 (QCA8172)
|
||||
dd 0x0
|
||||
|
||||
db 'BCM57XX', 0
|
||||
dd 0x164514e4 ; BCM5701
|
||||
dd 0x100010b7 ; 3c985
|
||||
dd 0x165414e4 ; BCM5705
|
||||
dd 0x167714e4 ; BCM5751
|
||||
dd 0x169214e4 ; BCM57780
|
||||
dd 0x0
|
||||
|
||||
dd 0x0 ; driverlist end
|
||||
@@ -50,6 +50,7 @@ VendorID 0x126C, 'Nortel Networks Corp.'
|
||||
VendorID 0x1317, 'Admtek Inc.'
|
||||
VendorID 0x13D1, 'Abocom Systems'
|
||||
VendorID 0x1432, 'Edimax Computer Co'
|
||||
VendorID 0x14E4, 'Broadcom Corp.'
|
||||
VendorID 0x14EA, 'Planex Communications Inc.'
|
||||
VendorID 0x1500, 'Lantech Computer Company'
|
||||
VendorID 0x1516, 'Myson Technology Inc.'
|
||||
|
||||
@@ -202,6 +202,8 @@ mainloop:
|
||||
mov bh, byte[ebp + interface.number]
|
||||
mov bl, 7
|
||||
mcall 76 ; Number of IP conflicts
|
||||
cmp eax, -1
|
||||
je @f
|
||||
cmp eax, [ebp + interface.ip_conflicts]
|
||||
je @f
|
||||
mov [ebp + interface.ip_conflicts], eax
|
||||
@@ -215,8 +217,8 @@ mainloop:
|
||||
mov bh, byte[ebp + interface.number]
|
||||
mov bl, 0 ; Get device type
|
||||
mcall 74
|
||||
test eax, eax ; No device
|
||||
jz .link_down
|
||||
cmp eax, 1
|
||||
jne .link_down
|
||||
|
||||
; Check if link is still there
|
||||
mov bl, 10 ; Get Link status
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
#include "../program_console.h"
|
||||
#include <shell_api.h>
|
||||
|
||||
|
||||
int program_console(int pid) {
|
||||
char name[32];
|
||||
char *buffer;
|
||||
struct shell_shm_buffer *buffer;
|
||||
char *buf1k;
|
||||
int result;
|
||||
int i;
|
||||
@@ -33,55 +32,55 @@ int program_console(int pid) {
|
||||
|
||||
is_end = 0;
|
||||
for (;;) {
|
||||
command = *(buffer);
|
||||
|
||||
command = buffer->cmd;
|
||||
|
||||
switch (command) {
|
||||
case SC_EXIT:
|
||||
*buffer = SC_OK;
|
||||
case SHELL_EXIT:
|
||||
buffer->cmd = SHELL_OK;
|
||||
is_end = 1;
|
||||
break;
|
||||
|
||||
case SC_OK:
|
||||
|
||||
case SHELL_OK:
|
||||
kol_sleep(5);
|
||||
break;
|
||||
|
||||
case SC_CLS:
|
||||
case SHELL_CLS:
|
||||
con_cls();
|
||||
*buffer = SC_OK;
|
||||
break;
|
||||
|
||||
case SC_PUTC:
|
||||
printf("%c", *(buffer+1));
|
||||
*buffer = SC_OK;
|
||||
buffer->cmd = SHELL_OK;
|
||||
break;
|
||||
|
||||
case SC_PUTS:
|
||||
printf("%s", buffer+1 );
|
||||
*buffer = SC_OK;
|
||||
case SHELL_PUTC:
|
||||
printf("%c", buffer->data[0]);
|
||||
buffer->cmd = SHELL_OK;
|
||||
break;
|
||||
|
||||
case SC_GETC:
|
||||
*(buffer+1) = (char) getch() ;
|
||||
*buffer = SC_OK;
|
||||
break;
|
||||
|
||||
case SC_GETS:
|
||||
gets(buffer+1, size-2);
|
||||
*buffer = SC_OK;
|
||||
break;
|
||||
|
||||
case SC_PID:
|
||||
case SHELL_PUTS:
|
||||
printf("%s", &buffer->data );
|
||||
buffer->cmd = SHELL_OK;
|
||||
break;
|
||||
|
||||
case SHELL_GETC:
|
||||
buffer->data[0] = (char) getch() ;
|
||||
buffer->cmd = SHELL_OK;
|
||||
break;
|
||||
|
||||
case SHELL_GETS:
|
||||
gets(buffer->data, size - 2);
|
||||
buffer->cmd = SHELL_OK;
|
||||
break;
|
||||
|
||||
case SHELL_PID:
|
||||
buf1k=malloc(1024);
|
||||
kol_process_info(-1, buf1k);
|
||||
memcpy(buffer+1, buf1k+30, sizeof(unsigned));
|
||||
*buffer = SC_OK;
|
||||
memcpy(buffer->data, buf1k+30, sizeof(unsigned));
|
||||
buffer->cmd = SHELL_OK;
|
||||
free(buf1k);
|
||||
break;
|
||||
|
||||
case SC_PING:
|
||||
*buffer = SC_OK;
|
||||
|
||||
case SHELL_PING:
|
||||
buffer->cmd = SHELL_OK;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
printf (CON_APP_ERROR);
|
||||
return 0;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../programs" or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
add_include(tup.getvariantdir())
|
||||
|
||||
tup.rule("Zune.dtp.asm", 'fasm "%f" "%o"', "Zune.dtp")
|
||||
tup.rule({"Zune.asm", extra_inputs = {"Zune.dtp"}}, FASM .. ' "%f" "%o" ' .. tup.getconfig("KPACK_CMD"), "Zune.skn")
|
||||
@@ -0,0 +1,31 @@
|
||||
include 'skin.inc'
|
||||
|
||||
SKIN_PARAMS \
|
||||
height = bmp_base.height,\ ; skin height
|
||||
margins = [5:1:43:1],\ ; margins [left:top:right:bottom]
|
||||
colors active = [binner=0x292929:\ ; border inner color
|
||||
bouter=0x1B1B1B:\ ; border outer color
|
||||
bframe=0x858585],\ ; border frame color
|
||||
colors inactive = [binner=0x4C4C4C:\ ; border inner color
|
||||
bouter=0x1B1B1B:\ ; border outer color
|
||||
bframe=0x555555],\ ; border frame color
|
||||
dtp = 'Zune.dtp' ; dtp colors
|
||||
|
||||
SKIN_BUTTONS \
|
||||
close = [-23:4][18:18],\ ; buttons coordinates
|
||||
minimize = [-42:4][18:18] ; [left:top][width:height]
|
||||
|
||||
SKIN_BITMAPS \
|
||||
left active = bmp_left,\ ; skin bitmaps pointers
|
||||
left inactive = bmp_left1,\
|
||||
oper active = bmp_oper,\
|
||||
oper inactive = bmp_oper1,\
|
||||
base active = bmp_base,\
|
||||
base inactive = bmp_base1
|
||||
|
||||
BITMAP bmp_left ,'active/left.bmp' ; skin bitmaps
|
||||
BITMAP bmp_oper ,'active/oper.bmp'
|
||||
BITMAP bmp_base ,'active/base.bmp'
|
||||
BITMAP bmp_left1,'inactive/left.bmp'
|
||||
BITMAP bmp_oper1,'inactive/oper.bmp'
|
||||
BITMAP bmp_base1,'inactive/base.bmp'
|
||||
@@ -0,0 +1,11 @@
|
||||
;SYSTEM COLORS (.DTP) - COMPILE WITH FASM
|
||||
frame dd 0x8A8A8A
|
||||
grab dd 0x8A8A8A
|
||||
grab_button dd 0xC6C9CB
|
||||
grab_button_text dd 0xFFFFFF
|
||||
grab_text dd 0xFFFFFF
|
||||
work dd 0xE2E2E2
|
||||
work_button dd 0xFF732B
|
||||
work_button_text dd 0xFFFFFF
|
||||
work_text dd 0x000000
|
||||
work_graph dd 0x9D9D9D
|
||||
|
After Width: | Height: | Size: 150 B |
|
After Width: | Height: | Size: 438 B |
|
After Width: | Height: | Size: 4.3 KiB |
@@ -0,0 +1,4 @@
|
||||
@del Zune.skn
|
||||
@fasm Zune.dtp.asm Zune.dtp
|
||||
@fasm Zune.asm Zune.skn
|
||||
@del Zune.dtp
|
||||
|
After Width: | Height: | Size: 150 B |
|
After Width: | Height: | Size: 438 B |
|
After Width: | Height: | Size: 4.3 KiB |
@@ -0,0 +1,239 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;============================================================================
|
||||
; This file should be used to generate skins of new standard
|
||||
;============================================================================
|
||||
; skin file structure:
|
||||
;----------------------------------------------------------------------------
|
||||
; header:
|
||||
; dd 'SKIN'
|
||||
; dd = version (1 for now)
|
||||
; dd @ params
|
||||
; dd @ buttons
|
||||
; dd @ bitmaps
|
||||
; ...
|
||||
;----------------------------------------------------------------------------
|
||||
; NOTE: order of sections listed below is insignificant
|
||||
; since they're identified by pointer in above header
|
||||
;----------------------------------------------------------------------------
|
||||
; ...
|
||||
; params:
|
||||
; dd = skin height
|
||||
; dw = right margin
|
||||
; dw = left margin
|
||||
; dw = bottom margin
|
||||
; dw = top margin
|
||||
; dd = inner line color
|
||||
; dd = outer line color
|
||||
; dd = frame color
|
||||
; dd = dtp file size
|
||||
; ?? = dtp file itself
|
||||
; ...
|
||||
;----------------------------------------------------------------------------
|
||||
; ...
|
||||
; buttons:
|
||||
; dd = button type (1 = close, 2 = minimize)
|
||||
; dw = left button coord (could be negative)
|
||||
; dw = top button coord (could be negative)
|
||||
; dw = button width
|
||||
; dw = button height
|
||||
; ... etc for all buttons
|
||||
; dd = 0 (end of buttons list)
|
||||
; ...
|
||||
;----------------------------------------------------------------------------
|
||||
; ...
|
||||
; bitmaps:
|
||||
; dw = bitmap kind (1 = left, 2 = oper, 3 = base)
|
||||
; dw = bitmap type (1 = active, 0 = inactive)
|
||||
; dd @ bitmap
|
||||
; ... etc for all bitmaps
|
||||
; dd 0 (end of bitmaps list)
|
||||
; ...
|
||||
;----------------------------------------------------------------------------
|
||||
; ...
|
||||
; bitmap:
|
||||
; dd = bitmap width
|
||||
; dd = bitmap height
|
||||
; ?? = raw bitmap data
|
||||
; ... etc for all bitmaps
|
||||
; ...
|
||||
;============================================================================
|
||||
|
||||
dd 'SKIN',1,__params__,__buttons__,__bitmaps__
|
||||
|
||||
struc BITMAPFILEHEADER {
|
||||
.bfType dw ? ; WORD
|
||||
.bfSize dd ? ; DWORD
|
||||
.bfReserved1 dw ? ; WORD
|
||||
.bfReserved2 dw ? ; WORD
|
||||
.bfOffBits dd ? ; DWORD
|
||||
}
|
||||
|
||||
struc BITMAPINFOHEADER {
|
||||
.biSize dd ? ; DWORD
|
||||
.biWidth dd ? ; LONG
|
||||
.biHeight dd ? ; LONG
|
||||
.biPlanes dw ? ; WORD
|
||||
.biBitCount dw ? ; WORD
|
||||
.biCompression dd ? ; DWORD
|
||||
.biSizeImage dd ? ; DWORD
|
||||
.biXPelsPerMeter dd ? ; LONG
|
||||
.biYPelsPerMeter dd ? ; LONG
|
||||
.biClrUsed dd ? ; DWORD
|
||||
.biClrImportant dd ? ; DWORD
|
||||
}
|
||||
|
||||
struc _bmp {
|
||||
.h BITMAPFILEHEADER
|
||||
.i BITMAPINFOHEADER
|
||||
}
|
||||
virtual at 0
|
||||
_bmp _bmp
|
||||
end virtual
|
||||
|
||||
macro BITMAP _name*,_fname*
|
||||
{
|
||||
local w,h,a,r,g,b
|
||||
virtual at 0
|
||||
_file equ _#_name
|
||||
_file::
|
||||
file _fname
|
||||
end virtual
|
||||
load w dword from _file:_bmp.i.biWidth
|
||||
load h dword from _file:_bmp.i.biHeight
|
||||
load hsize dword from _file:_bmp.h.bfOffBits
|
||||
align 4
|
||||
label _name
|
||||
.width = w
|
||||
.height = h
|
||||
dd w,h
|
||||
a=hsize+(w*3+(w mod 4))*(h-1)
|
||||
size = $
|
||||
repeat h
|
||||
repeat w
|
||||
load r from _file:a+0
|
||||
load g from _file:a+1
|
||||
load b from _file:a+2
|
||||
db r,g,b
|
||||
a=a+3
|
||||
end repeat
|
||||
a=a-w*3*2-(w mod 4)
|
||||
end repeat
|
||||
}
|
||||
|
||||
macro define_colors name,[col,val]
|
||||
{
|
||||
common
|
||||
local a,b,c
|
||||
forward
|
||||
match =binner,col \{ a = val \}
|
||||
match =bouter,col \{ b = val \}
|
||||
match =bframe,col \{ c = val \}
|
||||
common
|
||||
name equ a,b,c
|
||||
}
|
||||
|
||||
macro SKIN_PARAMS [a]
|
||||
{
|
||||
common
|
||||
local _height,_margins,_colors,_colors_1,_dtp
|
||||
__params__:
|
||||
forward
|
||||
match qq == ww,a
|
||||
\{
|
||||
match =height,qq \\{ _height = ww \\}
|
||||
match =margins,qq \\{
|
||||
match [q1:q2:q3:q4],ww
|
||||
\\\{
|
||||
_margins equ q3,q1,q4,q2
|
||||
\\\}
|
||||
\\}
|
||||
match =colors =active,qq
|
||||
\\{
|
||||
match [q10==q11:q20==q21:q30==q31],ww
|
||||
\\\{
|
||||
define_colors _colors,q10,q11,q20,q21,q30,q31
|
||||
\\\}
|
||||
\\}
|
||||
match =colors =inactive,qq
|
||||
\\{
|
||||
match [q10==q11:q20==q21:q30==q31],ww
|
||||
\\\{
|
||||
define_colors _colors_1,q10,q11,q20,q21,q30,q31
|
||||
\\\}
|
||||
\\}
|
||||
match =dtp,qq \\{ _dtp equ ww \\}
|
||||
\}
|
||||
common
|
||||
dd _height
|
||||
dw _margins
|
||||
dd _colors,_colors_1
|
||||
dd @f - $ - 4
|
||||
file _dtp
|
||||
@@:
|
||||
}
|
||||
|
||||
macro SKIN_BUTTONS [a]
|
||||
{
|
||||
common
|
||||
local btn
|
||||
__buttons__:
|
||||
forward
|
||||
match qq == ww,a
|
||||
\{
|
||||
btn = 0
|
||||
match =close,qq \\{ btn = 1 \\}
|
||||
match =minimize,qq \\{ btn = 2 \\}
|
||||
match [q1:q2][q3:q4],ww
|
||||
\\{
|
||||
if btn <> 0
|
||||
dd btn
|
||||
dw q1,q2,q3,q4
|
||||
end if
|
||||
\\}
|
||||
\}
|
||||
common
|
||||
dd 0
|
||||
}
|
||||
|
||||
macro SKIN_BITMAPS [a]
|
||||
{
|
||||
common
|
||||
local bmp
|
||||
__bitmaps__:
|
||||
forward
|
||||
match qq == ww,a
|
||||
\{
|
||||
bmp=-1
|
||||
match qqq =active,qq \\{ bmp = 1 \\}
|
||||
match qqq =inactive,qq \\{ bmp = 0 \\}
|
||||
match =left qqq,qq
|
||||
\\{
|
||||
if bmp >= 0
|
||||
dw 1,bmp
|
||||
dd ww
|
||||
end if
|
||||
\\}
|
||||
match =oper qqq,qq
|
||||
\\{
|
||||
if bmp >= 0
|
||||
dw 2,bmp
|
||||
dd ww
|
||||
end if
|
||||
\\}
|
||||
match =base qqq,qq
|
||||
\\{
|
||||
if bmp >= 0
|
||||
dw 3,bmp
|
||||
dd ww
|
||||
end if
|
||||
\\}
|
||||
\}
|
||||
common
|
||||
dd 0
|
||||
}
|
||||
@@ -76,4 +76,5 @@ skinlist = {
|
||||
"_old/WindowsXP/WinXP Standard blue/WinXP Standard blue.skn",
|
||||
"_old/WindowsXP/WinXP Standard olive_green/WinXP Standard olive_green.skn",
|
||||
"_old/WindowsXP/WinXP Standard silver/WinXP Standard silver.skn",
|
||||
"Weronika_Saturday/Zune/Zune.skn",
|
||||
}
|
||||