com32/chain: make raw handover use total sectors info
[syslinux.git] / core / cmdline.inc
blob3e63f9ab15ca13260157257ca373ee2f883729ce
1 ;; -----------------------------------------------------------------------
2 ;;
3 ;;   Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
4 ;;   Copyright 2009 Intel Corporation; author: H. Peter Anvin
5 ;;
6 ;;   This program is free software; you can redistribute it and/or modify
7 ;;   it under the terms of the GNU General Public License as published by
8 ;;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ;;   Boston MA 02111-1307, USA; either version 2 of the License, or
10 ;;   (at your option) any later version; incorporated herein by reference.
12 ;; -----------------------------------------------------------------------
15 ;; cmdline.inc
17 ;; Common routine to assemble [null-terminated] command line into
18 ;; real_mode_seg:cmd_line_here.
19 ;; Not used by plain kernel due to BOOT_IMAGE= etc.
22                 section .text16
25 ; Assumes DS == CS
27 make_plain_cmdline:
28                 push es
29                 ; ui.inc has already copied any APPEND options
30                 mov ax,real_mode_seg
31                 mov es,ax
33                 mov di,[CmdLinePtr]
34                 call do_ip_append
36                 mov si,[CmdOptPtr]
38                 call strcpy
40                 dec di
41                 mov [CmdLinePtr],di
42                 mov byte [es:di],0              ; Null-terminate
44                 pop es
45                 ret
48 ; Actual IPAppend strings...
50 %if IS_PXELINUX
51                 extern IPOption, BOOTIFStr, SYSUUIDStr
52                 global IPAppends, numIPAppends
54                 section .data16
55                 alignz 2
56 IPAppends       dw IPOption
57                 dw BOOTIFStr
58                 dw SYSUUIDStr
59 numIPAppends    equ ($-IPAppends)/2
60 %else
61 IPAppends       equ 0
62 numIPAppends    equ 0
63 %endif
66 ; Handle "ipappend" strings, if applicable
68 ; Assumes DS == CS; pushes output to ES:DI
70                 section .text16
72 do_ip_append:
73 %ifndef DEPEND
74  %if numIPAppends > 0
75                 push cx
76                 push bx
77                 push si
79                 mov bx,IPAppends
80                 mov cx,[IPAppend]
81                 and cx,(1 << numIPAppends)-1
82 .loop:
83                 jcxz .done
84                 mov si,[bx]
85                 inc bx
86                 inc bx
87                 test cl,1
88                 jz .not_this
90                 call strcpy
91                 mov byte [es:di-1],' '  ; Replace final null with space
92 .not_this:
93                 shr cx,1
94                 jmp .loop
95 .done:
96                 pop si
97                 pop bx
98                 pop cx
99  %endif
100 %endif
101                 ret