aboutsummaryrefslogtreecommitdiff
path: root/slof
diff options
context:
space:
mode:
authorNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2017-12-12 11:07:13 +0530
committerAlexey Kardashevskiy <aik@ozlabs.ru>2017-12-13 12:54:06 +1100
commit80f74b855f2f67ae5ed45b0d32c57dce46585da7 (patch)
treeed165f0a89703d2eb93dcf8ca33f177c31e907b3 /slof
parent1e8f6e68d28132e70898bd4bd6f799b591c3bf2b (diff)
downloadSLOF-80f74b855f2f67ae5ed45b0d32c57dce46585da7.zip
SLOF-80f74b855f2f67ae5ed45b0d32c57dce46585da7.tar.gz
SLOF-80f74b855f2f67ae5ed45b0d32c57dce46585da7.tar.bz2
boot: use a temporary bootdev-buf
The catpad size is 1K size, which can overflow easily with around 20 devices having bootindex. Replace usage of $cat with a dynamically allocated buffer(16K) here. Introduce new words to work on the buffer (allocate, free and concatenate) Reported here: https://github.com/qemu/SLOF/issues/3 Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'slof')
-rw-r--r--slof/fs/boot.fs41
1 files changed, 38 insertions, 3 deletions
diff --git a/slof/fs/boot.fs b/slof/fs/boot.fs
index 5d41a0e..6d16c54 100644
--- a/slof/fs/boot.fs
+++ b/slof/fs/boot.fs
@@ -15,8 +15,27 @@
VARIABLE state-valid false state-valid !
CREATE go-args 2 cells allot go-args 2 cells erase
+4000 CONSTANT bootdev-size
+0 VALUE bootdev-buf
+
\ \\\\\\\\\\\\\\ Structure/Implementation Dependent Methods
+: alloc-bootdev-buf ( -- )
+ bootdev-size alloc-mem ?dup 0= ABORT" Unable to allocate bootdev buffer!"
+ dup bootdev-size erase
+ to bootdev-buf
+;
+
+: free-bootdev-buf ( -- )
+ bootdev-buf bootdev-size free-mem
+ 0 to bootdev-buf
+;
+
+: bootdev-string-cat ( addr1 len1 addr2 len2 -- addr1 len1+len2 )
+ dup 3 pick + bootdev-size > ABORT" bootdev size too big!"
+ string-cat
+;
+
: $bootargs
bootargs 2@ ?dup IF
ELSE s" diagnostic-mode?" evaluate and IF s" diag-file" evaluate
@@ -24,14 +43,23 @@ CREATE go-args 2 cells allot go-args 2 cells erase
;
: $bootdev ( -- device-name len )
- bootdevice 2@ dup IF s" " $cat THEN
+ alloc-bootdev-buf
+ bootdevice 2@ ?dup IF
+ swap bootdev-buf 2 pick move
+ bootdev-buf swap s" " bootdev-string-cat
+ ELSE
+ \ use bootdev-buf for concatenating diag mode/boot-device if any
+ drop bootdev-buf 0
+ THEN
s" diagnostic-mode?" evaluate IF
s" diag-device" evaluate
ELSE
s" boot-device" evaluate
THEN
- $cat \ prepend bootdevice setting from vpd-bootlist
+ ( bootdev len str len1 )
+ bootdev-string-cat \ concatenate both
strdup
+ free-bootdev-buf
?dup 0= IF
disable-watchdog
drop true ABORT" No boot device!"
@@ -51,7 +79,14 @@ CREATE go-args 2 cells allot go-args 2 cells erase
' (set-boot-device) to set-boot-device
: (add-boot-device) ( str len -- ) \ Concatenate " str" to "bootdevice"
- bootdevice 2@ ?dup IF $cat-space ELSE drop THEN set-boot-device
+ bootdevice 2@ ?dup IF
+ alloc-bootdev-buf
+ swap bootdev-buf 2 pick move
+ bootdev-buf swap s" " bootdev-string-cat
+ 2swap bootdev-string-cat
+ ELSE drop THEN
+ set-boot-device
+ bootdev-buf 0 <> IF free-bootdev-buf THEN
;
' (add-boot-device) to add-boot-device