/[pupa]/pupa/kern/i386/pc/startup.S
ViewVC logotype

Diff of /pupa/kern/i386/pc/startup.S

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by okuji, Fri Dec 27 08:53:09 2002 UTC revision 1.2 by okuji, Sat Dec 28 07:16:30 2002 UTC
# Line 35  Line 35 
35  {  1, 1, 1, 0, 0, 0, 0, 1, 1,  1,  1,  1,  1,  1,  1,  1,  1 }  {  1, 1, 1, 0, 0, 0, 0, 1, 1,  1,  1,  1,  1,  1,  1,  1,  1 }
36   */   */
37    
38    /*
39     * Note: PUPA is compiled with the options -mrtd and -mregparm=3.
40     *       So the first three arguments are passed in %eax, %edx, and %ecx,
41     *       respectively, and if a function has a fixed number of arguments
42     *       and the number if greater than three, the function must return
43     *       with "ret $N" where N is ((the number of arguments) - 3) * 4.
44     */
45    
46  #include <config.h>  #include <config.h>
47  #include <pupa/symbol.h>  #include <pupa/symbol.h>
48  #include <pupa/boot.h>  #include <pupa/boot.h>
# Line 203  FUNCTION(pupa_reboot) Line 211  FUNCTION(pupa_reboot)
211   * APM even if it is available.   * APM even if it is available.
212   */   */
213  FUNCTION(pupa_halt)  FUNCTION(pupa_halt)
         /* get the argument */  
         movl    4(%esp), %eax  
           
214          /* see if zero */          /* see if zero */
215          testl   %eax, %eax          testl   %eax, %eax
216          jnz     EXT_C(pupa_stop)          jnz     EXT_C(pupa_stop)
# Line 256  FUNCTION(pupa_halt) Line 261  FUNCTION(pupa_halt)
261   */   */
262    
263  FUNCTION(pupa_chainloader_real_boot)  FUNCTION(pupa_chainloader_real_boot)
264          /* no need to save anything, just use %esp */          /* no need to save anything */
265    
266          /* ESI must point to a partition table entry */          /* ESI must point to a partition table entry */
267          movl    8(%esp), %esi          movl    %edx, %esi
268    
269          /* set up to pass boot drive */          /* set up to pass boot drive */
270          movl    4(%esp), %edx          movl    %eax, %edx
271    
272          /* Turn off Gate A20 */          /* Turn off Gate A20 */
273          pushl   $0          xorl    %eax, %eax
274          call    EXT_C(pupa_gate_a20)          call    EXT_C(pupa_gate_a20)
275                    
276          call    prot_to_real          call    prot_to_real
# Line 398  realcseg: Line 403  realcseg:
403    
404  FUNCTION(pupa_biosdisk_rw_int13_extensions)  FUNCTION(pupa_biosdisk_rw_int13_extensions)
405          pushl   %ebp          pushl   %ebp
         movl    %esp, %ebp  
   
406          pushl   %esi          pushl   %esi
407    
408          /* compute the address of disk_address_packet */          /* compute the address of disk_address_packet */
409          movl    0x10(%ebp), %eax          movw    %cx, %si
410          movw    %ax, %si          xorw    %cx, %cx
411          xorw    %ax, %ax          shrl    $4, %ecx        /* save the segment to cx */
         shrl    $4, %eax  
         movw    %ax, %cx        /* save the segment to cx */  
412    
         /* drive */  
         movb    0xc(%ebp), %dl  
413          /* ah */          /* ah */
414          movb    0x8(%ebp), %dh          movb    %al, %dh
415          /* enter real mode */          /* enter real mode */
416          call    prot_to_real          call    prot_to_real
417                    
# Line 453  FUNCTION(pupa_biosdisk_rw_standard) Line 452  FUNCTION(pupa_biosdisk_rw_standard)
452          pushl   %esi          pushl   %esi
453    
454          /* set up CHS information */          /* set up CHS information */
455          movl    0x10(%ebp), %eax  
456          movb    %al, %ch          /* set %ch to low eight bits of cylinder */
457          movb    0x18(%ebp), %al          xchgb   %cl, %ch
458          shlb    $2, %al          /* set bits 6-7 of %cl to high two bits of cylinder */
459          shrw    $2, %ax          shlb    $6, %cl
460          movb    %al, %cl          /* set bits 0-5 of %cl to sector */
461          movb    0x14(%ebp), %dh          addb    0xc(%ebp), %cl
462          /* drive */          /* set %dh to head */
463          movb    0xc(%ebp), %dl          movb    0x8(%ebp), %dh
464          /* segment */          /* set %ah to AH */
465          movw    0x20(%ebp), %bx          movb    %al, %ah
466          /* save nsec and ah to %di */          /* set %al to NSEC */
467          movb    0x8(%ebp), %ah          movb    0x10(%ebp), %al
468          movb    0x1c(%ebp), %al          /* save %ax in %di */
469          movw    %ax, %di          movw    %ax, %di
470            /* save SEGMENT in %bx */
471            movw    0x14(%ebp), %bx
472                    
473          /* enter real mode */          /* enter real mode */
474          call    prot_to_real          call    prot_to_real
475    
# Line 503  FUNCTION(pupa_biosdisk_rw_standard) Line 505  FUNCTION(pupa_biosdisk_rw_standard)
505          popl    %ebx          popl    %ebx
506          popl    %ebp          popl    %ebp
507    
508          ret          ret     $(4 * 4)
509    
510    
511  /*  /*
# Line 515  FUNCTION(pupa_biosdisk_rw_standard) Line 517  FUNCTION(pupa_biosdisk_rw_standard)
517    
518  FUNCTION(pupa_biosdisk_check_int13_extensions)  FUNCTION(pupa_biosdisk_check_int13_extensions)
519          pushl   %ebp          pushl   %ebp
         movl    %esp, %ebp  
   
520          pushl   %ebx          pushl   %ebx
521    
522          /* drive */          /* drive */
523          movb    0x8(%ebp), %dl          movb    %al, %dl
524          /* enter real mode */          /* enter real mode */
525          call    prot_to_real          call    prot_to_real
526    
# Line 564  FUNCTION(pupa_biosdisk_check_int13_exten Line 564  FUNCTION(pupa_biosdisk_check_int13_exten
564    
565  FUNCTION(pupa_biosdisk_get_diskinfo_int13_extensions)  FUNCTION(pupa_biosdisk_get_diskinfo_int13_extensions)
566          pushl   %ebp          pushl   %ebp
         movl    %esp, %ebp  
   
567          pushl   %ebx          pushl   %ebx
568          pushl   %esi          pushl   %esi
569    
570          /* compute the address of drive parameters */          /* compute the address of drive parameters */
571          movl    0xc(%ebp), %eax          movw    %dx, %si
572          movw    %ax, %si          xorw    %dx, %dx
573          xorw    %ax, %ax          shrl    $4, %edx
574          shrl    $4, %eax          movw    %dx, %bx        /* save the segment into %bx */
         movw    %ax, %bx        /* save the segment into %bx */  
575          /* drive */          /* drive */
576          movb    0x8(%ebp), %dl          movb    %al, %dl
577          /* enter real mode */          /* enter real mode */
578          call    prot_to_real          call    prot_to_real
579    
# Line 613  FUNCTION(pupa_biosdisk_get_diskinfo_int1 Line 610  FUNCTION(pupa_biosdisk_get_diskinfo_int1
610    
611  FUNCTION(pupa_biosdisk_get_diskinfo_standard)  FUNCTION(pupa_biosdisk_get_diskinfo_standard)
612          pushl   %ebp          pushl   %ebp
         movl    %esp, %ebp  
   
613          pushl   %ebx          pushl   %ebx
614          pushl   %edi          pushl   %edi
615    
616            /* push CYLINDERS */
617            pushl   %edx
618            /* push HEADS */
619            pushl   %ecx
620            /* SECTORS is on the stack */
621            
622          /* drive */          /* drive */
623          movb    0x8(%ebp), %dl          movb    %al, %dl
624          /* enter real mode */          /* enter real mode */
625          call    prot_to_real          call    prot_to_real
626    
# Line 640  FUNCTION(pupa_biosdisk_get_diskinfo_stan Line 641  FUNCTION(pupa_biosdisk_get_diskinfo_stan
641          DATA32  call    real_to_prot          DATA32  call    real_to_prot
642          .code32          .code32
643    
644          /* restore %ebp */          /* pop HEADS */
645          leal    0x8(%esp), %ebp          popl    %edi
           
         /* heads */  
646          movb    %dh, %al          movb    %dh, %al
647          incl    %eax            /* the number of heads is counted from zero */          incl    %eax    /* the number of heads is counted from zero */
         movl    0x10(%ebp), %edi  
648          movl    %eax, (%edi)          movl    %eax, (%edi)
649    
650          /* sectors */          /* pop CYLINDERS */
651          xorl    %eax, %eax          popl    %edi
         movb    %cl, %al  
         andb    $0x3f, %al  
         movl    0x14(%ebp), %edi  
         movl    %eax, (%edi)  
   
         /* cylinders */  
         shrb    $6, %cl  
         movb    %cl, %ah  
652          movb    %ch, %al          movb    %ch, %al
653          incl    %eax            /* the number of cylinders is          movb    %cl, %ah
654                                     counted from zero */          shrb    $6, %ah /* the number of cylinders is counted from zero */
655          movl    0xc(%ebp), %edi          incl    %eax
656          movl    %eax, (%edi)          movl    %eax, (%edi)
657    
658            /* SECTORS */
659            movl    0x10(%esp), %edi
660            andb    $0x3f, %cl
661            movzbl  %cl, %eax
662            movl    %eax, (%edi)
663            
664          xorl    %eax, %eax          xorl    %eax, %eax
665          movb    %bl, %al        /* return value in %eax */          movb    %bl, %al        /* return value in %eax */
666    
# Line 672  FUNCTION(pupa_biosdisk_get_diskinfo_stan Line 668  FUNCTION(pupa_biosdisk_get_diskinfo_stan
668          popl    %ebx          popl    %ebx
669          popl    %ebp          popl    %ebp
670    
671          ret          ret     $4
672    
673    
674  /*  /*
# Line 724  FUNCTION(pupa_biosdisk_get_num_floppies) Line 720  FUNCTION(pupa_biosdisk_get_num_floppies)
720    
721  FUNCTION(pupa_get_memsize)  FUNCTION(pupa_get_memsize)
722          pushl   %ebp          pushl   %ebp
         pushl   %ebx  
723    
724          movl    0xc(%esp), %ebx          movl    %eax, %edx
725    
726          call    prot_to_real    /* enter real mode */          call    prot_to_real    /* enter real mode */
727          .code16          .code16
728    
729          testl   %ebx, %ebx          testl   %edx, %edx
730          jnz     xext          jnz     xext
731    
732          int     $0x12          int     $0x12
# Line 742  xext: Line 737  xext:
737          int     $0x15          int     $0x15
738    
739  xdone:  xdone:
740          movw    %ax, %bx          movw    %ax, %dx
741    
742          DATA32  call    real_to_prot          DATA32  call    real_to_prot
743          .code32          .code32
744    
745          movw    %bx, %ax          movw    %dx, %ax
746          popl    %ebx  
747          popl    %ebp          popl    %ebp
748          ret          ret
749    
# Line 802  xnoteisa: Line 797  xnoteisa:
797   */   */
798    
799  FUNCTION(pupa_get_mmap_entry)  FUNCTION(pupa_get_mmap_entry)
800          push    %ebp          pusha
         push    %ebx  
         push    %edi  
         push    %esi  
801    
802            /* push ADDR */
803            pushl   %eax
804            
805          /* place address (+4) in ES:DI */          /* place address (+4) in ES:DI */
         movl    0x14(%esp), %eax  
806          addl    $4, %eax          addl    $4, %eax
807          movl    %eax, %edi          movl    %eax, %edi
808          andl    $0xf, %edi          andl    $0xf, %edi
# Line 816  FUNCTION(pupa_get_mmap_entry) Line 810  FUNCTION(pupa_get_mmap_entry)
810          movl    %eax, %esi          movl    %eax, %esi
811    
812          /* set continuation value */          /* set continuation value */
813          movl    0x18(%esp), %ebx          movl    %edx, %ebx
814    
815          /* set default maximum buffer size */          /* set default maximum buffer size */
816          movl    $0x14, %ecx          movl    $0x14, %ecx
# Line 851  xsmap: Line 845  xsmap:
845          DATA32  call    real_to_prot          DATA32  call    real_to_prot
846          .code32          .code32
847    
848          /* write length of buffer (zero if error) into "addr" */          /* write length of buffer (zero if error) into ADDR */
849          movl    0x14(%esp), %eax          popl    %eax
850          movl    %ecx, (%eax)          movl    %ecx, (%eax)
851    
852          /* set return value to continuation */          /* set return value to continuation */
853          movl    %ebx, %eax          movl    %ebx, %eax
854    
855          pop     %esi          popa
         pop     %edi  
         pop     %ebx  
         pop     %ebp  
856          ret          ret
857    
858                    
# Line 937  gloop2ret: Line 928  gloop2ret:
928   * support setting a background attribute.   * support setting a background attribute.
929   */   */
930  FUNCTION(pupa_console_putchar)  FUNCTION(pupa_console_putchar)
931          movl    0x4(%esp), %edx          movl    %eax, %edx
932          pusha          pusha
933          movb    EXT_C(pupa_console_cur_color), %bl          movb    EXT_C(pupa_console_cur_color), %bl
934                    
# Line 1122  FUNCTION(pupa_console_gotoxy) Line 1113  FUNCTION(pupa_console_gotoxy)
1113          pushl   %ebp          pushl   %ebp
1114          pushl   %ebx                    /* save EBX */          pushl   %ebx                    /* save EBX */
1115    
1116          movb    0xc(%esp), %dl           /* %dl = x */          movb    %dl, %dh        /* %dh = y */
1117          movb    0x10(%esp), %dh          /* %dh = y */          movb    %al, %dl        /* %dl = x */
1118    
1119          call    prot_to_real          call    prot_to_real
1120          .code16          .code16
# Line 1195  console_cursor_shape: Line 1186  console_cursor_shape:
1186          .word   0          .word   0
1187                    
1188  FUNCTION(pupa_console_setcursor)  FUNCTION(pupa_console_setcursor)
1189          push    %ebp          pushl   %ebp
1190          push    %ebx          pushl   %ebx
1191    
1192            /* push ON */
1193            pushl   %eax
1194            
1195          /* check if the standard cursor shape has already been saved */          /* check if the standard cursor shape has already been saved */
1196          movw    console_cursor_shape, %ax          movw    console_cursor_shape, %ax
1197          testw   %ax, %ax          testw   %ax, %ax
# Line 1217  FUNCTION(pupa_console_setcursor) Line 1211  FUNCTION(pupa_console_setcursor)
1211  1:  1:
1212          /* set %cx to the designated cursor shape */          /* set %cx to the designated cursor shape */
1213          movw    $0x2000, %cx          movw    $0x2000, %cx
1214          movl    0xc(%esp), %ebx          popl    %eax
1215          testl   %ebx, %ebx          testl   %eax, %eax
1216          jz      2f          jz      2f
1217          movw    console_cursor_shape, %cx          movw    console_cursor_shape, %cx
1218  2:        2:      
# Line 1254  FUNCTION(pupa_console_setcursor) Line 1248  FUNCTION(pupa_console_setcursor)
1248   *                          that it isn't running)   *                          that it isn't running)
1249   */   */
1250  FUNCTION(pupa_getrtsecs)  FUNCTION(pupa_getrtsecs)
1251          push    %ebp          pushl   %ebp
1252    
1253          call    prot_to_real    /* enter real mode */          call    prot_to_real    /* enter real mode */
1254          .code16          .code16
# Line 1272  gottime: Line 1266  gottime:
1266    
1267          movb    %dh, %al          movb    %dh, %al
1268    
1269          pop     %ebp          popl    %ebp
1270          ret          ret
1271    
1272                    

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26