Skip to content
Snippets Groups Projects
sglist.cc 491 B
Newer Older
  • Learn to ignore specific revisions
  • Dor Laor's avatar
    Dor Laor committed
    #include "sglist.hh"
    #include "debug.hh"
    
    void
    sglist::dump() {
        debug(fmt("nsgs=%d, max=%d") % _nsgs % _max_sgs);
        for (auto i = _nodes.begin(); i != _nodes.end(); i++) {
            debug(fmt("\t paddr=%x, len=%d") % i->_paddr, i->_len);
        }
    }
    
    bool
    
    sglist::add(u64 paddr, u32 len, bool front) {
    
    Dor Laor's avatar
    Dor Laor committed
        if (_nsgs == max_sgs)
            return false;
    
        sg_node n(paddr, len);
    
        auto ii = (front)? _nodes.begin() : _nodes.end();
        _nodes.insert(ii, n);
    
    Dor Laor's avatar
    Dor Laor committed
        _nsgs++;
    
        return true;
    }