Skip to content

Commit

Permalink
ia32: add option to run secondary psh
Browse files Browse the repository at this point in the history
JIRA: RTOS-998
  • Loading branch information
badochov committed Feb 4, 2025
1 parent 28928f0 commit 3a63275
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions _projects/ia32-generic-qemu/rootfs-overlay/etc/rc.psh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ X /bin/posixsrv
X /sbin/lwip rtl:0x18:11
T /dev/console
X /bin/psh
X /bin/psh -i /etc/secondary.psh
21 changes: 21 additions & 0 deletions _targets/ia32/generic/build.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CROSS=i386-pc-phoenix-
: "${CONSOLE=vga}"

export CONSOLE
export TTY
export BUSYBOX_CONFIG=$(realpath "busybox_config")
export DROPBEAR_CUSTOM_CFLAGS="-DLTC_NO_BSWAP"
export PSH_DEFUSRPWDHASH="0B1ANiYi45IhxkfmUW155/GBd4IRE="
Expand Down Expand Up @@ -48,12 +49,20 @@ export BOOT_DEVICE="hd0" # Default boot device
export MAGIC_USER_SCRIPT="baadf00d" # User script magic value


SECONDARY_TTY=
if [ "$CONSOLE" = "serial" ]; then
CONSOLE_APP="uart16550"
if [[ "$TTY" =~ "vga" ]]; then
SECONDARY_TTY="pc-tty"
fi
else
CONSOLE_APP="pc-tty"
if [[ "$TTY" =~ "serial" ]]; then
SECONDARY_TTY="uart16550"
fi
fi

export SECONDARY_TTY
export CONSOLE_APP


Expand All @@ -80,6 +89,18 @@ b_image_target() {
SIZE_PARTITION_KB=$(image_builder.py query --nvm "$NVM_CONFIG" '{{ nvm.hd0.rootfs.size // 1024 }}')

rm -f "$ROOTFS"

# Indicate that there is a secondary psh shell to run.
echo ":{}:" > "$PREFIX_ROOTFS/etc/secondary.psh"
case "$SECONDARY_TTY" in
"uart16550" )
echo -e "T /dev/ttyS0\nX /bin/psh -t /dev/ttyS0" >> "$PREFIX_ROOTFS/etc/secondary.psh"
;;
"pc-tty" )
echo -e "T /dev/tty0\nX /bin/psh -t /dev/tty0" >> "$PREFIX_ROOTFS/etc/secondary.psh"
;;
esac

SIZE_ROOTFS=$(du -ks "$PREFIX_ROOTFS" | cut -f 1)
echo "rootfs size: ${SIZE_ROOTFS} kB / $((SIZE_PARTITION_KB)) kB"
[ "$SIZE_ROOTFS" -gt "$SIZE_PARTITION_KB" ] && b_die "rootfs size exceeds the target partition!"
Expand Down
5 changes: 1 addition & 4 deletions _targets/ia32/generic/preinit.plo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ contents:
- phfs hd1 2.2 raw
- phfs hd2 2.3 raw
- phfs hd3 2.4 raw
- if: '{{ env.CONSOLE == "serial" }}'
str: console 0.0
- if: '{{ env.CONSOLE != "serial" }}'
str: console 3.0
- console {{ 0.0 if env.CONSOLE == "serial" else 3.0 }} {{ 0.0 if env.SECONDARY_TTY == "uart16550" else 3.0 if env.SECONDARY_TTY == "pc-tty" else "" }}
- wait 1000
- if: '{{ not(env.RAM_SCRIPT) | default(false) }}'
action: call
Expand Down
2 changes: 2 additions & 0 deletions _targets/ia32/generic/user.plo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ is_relative: True
contents:
- kernel {{ env.BOOT_DEVICE }}
- app {{ env.BOOT_DEVICE }} -x dummyfs;-N;devfs;-D ram ram
- if: '{{ env.SECONDARY_TTY != "" }}'
str: app {{ env.BOOT_DEVICE }} -x {{ env.SECONDARY_TTY }};-n ram ram
- app {{ env.BOOT_DEVICE }} -x {{ env.CONSOLE_APP }} ram ram
- app {{ env.BOOT_DEVICE }} -x psh;-i;/etc/rc.psh ram ram
- app {{ env.BOOT_DEVICE }} -x pc-ata ram ram
Expand Down
4 changes: 2 additions & 2 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ fi

if [ "$#" -eq 1 ] && [ "$1" = "bash" ]; then
# run interactive shell - using ROOT user
exec docker run -it --rm -v "${PATH_TO_PROJECT}:/src" -w /src -e TARGET -e SYSPAGE -e CONSOLE -e LONG_TEST -e SIL -e DEBUG --entrypoint bash "$DOCKER_IMG_NAME"
exec docker run -it --rm -v "${PATH_TO_PROJECT}:/src" -w /src -e TARGET -e SYSPAGE -e CONSOLE -e TTY -e LONG_TEST -e SIL -e DEBUG --entrypoint bash "$DOCKER_IMG_NAME"
else
# run build - use our own UID/GID to create files with correct owner
exec docker run -it --user "$DOCKER_USER" --rm -v "${PATH_TO_PROJECT}:/src:delegated" -w /src "${TMPFS_OVERLAY[@]}" -e TARGET -e SYSPAGE -e CONSOLE -e LONG_TEST -e SIL -e DEBUG "$DOCKER_IMG_NAME" "$@"
exec docker run -it --user "$DOCKER_USER" --rm -v "${PATH_TO_PROJECT}:/src:delegated" -w /src "${TMPFS_OVERLAY[@]}" -e TARGET -e SYSPAGE -e CONSOLE -e TTY -e LONG_TEST -e SIL -e DEBUG "$DOCKER_IMG_NAME" "$@"
fi

2 changes: 1 addition & 1 deletion phoenix-rtos-devices
2 changes: 1 addition & 1 deletion phoenix-rtos-kernel
2 changes: 1 addition & 1 deletion phoenix-rtos-utils
Submodule phoenix-rtos-utils updated 1 files
+3 −1 psh/psh.c
2 changes: 1 addition & 1 deletion plo

0 comments on commit 3a63275

Please sign in to comment.