ó
ëÑ…Sc           @   s]   d  d l  Z  d  d l Z d  d l m Z d „  Z d „  Z d „  Z e d k rY e ƒ  n  d S(   iÿÿÿÿN(   t   as_bytesc         C   s   | d } |  | | @S(   Ni   (    (   t   post
   alignbytest   mask(    (    sB   /home/kevin/src/coreboot/seabios-other/seabios/scripts/buildrom.pyt   alignpos   s    
c         C   sK   t  j d k r t |  ƒ } n t t t |  ƒ ƒ } t j d d | d @ƒ S(   Ni   i    s   <Bi   iÿ   (   i   i    (   t   syst   version_infot   sumt   mapt   ordt   structt   pack(   t   datat   cksum(    (    sB   /home/kevin/src/coreboot/seabios-other/seabios/scripts/buildrom.pyt   checksum   s    c          C   sv  t  j d }  t  j d } t |  d ƒ } | j ƒ  } | j ƒ  t | ƒ } | t d ƒ t | d ƒ | 7} t | ƒ } t | d d !ƒ t | d d !ƒ d	 >} | d
 k ré t	 j
 d t | d ƒ ƒ } | | d  | | | d } n  t	 j
 d t | d ƒ ƒ } | d  | | d d !t d ƒ | d } | d  t | ƒ | d } t | d ƒ } | j | ƒ | j ƒ  d  S(   Ni   i   t   rbt    i   i   i   i   i   i    s   <Hi   i   s   <Bi   i   i   t   wb(   R   t   argvt   opent   readt   closet   lenR    R   R	   R
   R   t   intR   t   write(   t   innamet   outnamet   fR   t   countt   pcidatat   blocks(    (    sB   /home/kevin/src/coreboot/seabios-other/seabios/scripts/buildrom.pyt   main   s$    
!(!+t   __main__(   R   R
   t   python23compatR    R   R   R   t   __name__(    (    (    sB   /home/kevin/src/coreboot/seabios-other/seabios/scripts/buildrom.pyt   <module>   s   			 